﻿using System;
using System.Collections.Generic;
using System.Web;
using ZLDC.Common.Estate;
using ZLDC.Common.BaseUser;
using ZLDC.Topo.BLL.Estate;
using System.Data;
using ZLDC.Topo.Model.Estate;

namespace ZLDC.Estate
{
    public class CHandlerHousing
    {
                        public static void ChooseMethod()
        {
            
            string act = _Request.GetString("act", "");
            switch (act)
            {
                #region 盘源管理


                case "GetInfo":                                         GetInfo();
                    break;
                case "insert":
                    HousingSave();
                    break;
                case "change_insert":
                    ChangeHousingSave();                                break;
                case "housing_list":
                    HousingList();
                    break;
                case "DelHousingFavorite":
                    DelHousingFavorite();
                    break;
                case "housing_list_action":
                    HousingListAction();
                    break;
                case "housinglock_list":
                    HousingLockList();                                  break;
                case "housingtype_list":
                    HousingTypeList();                                  break;
                case "housing_list_bytradetype":
                    HousingListByTradetype();                           break;
                case "housing_detail":
                    HousingDetail();
                    break;
                case "housing_del":
                    HousingDel();
                    break;
                case "housing_recommend":
                    HousingRecommend();
                    break;
                case "housing_favorite":
                    HousingFavorite();
                    break;
                case "housing_lock":
                    HousingLock();
                    break;
                case "ListByType":
                    ListByType();
                    break;
                case "SelectHousig":
                    SelectHousig();
                    break;
                case "showOtherHousing":
                    ShowOtherHousing();                                 break;

                #endregion

                case "HFollow":
                    p_housingFollow_save();
                    break;
                case "HFollow2":
                    p_housingFollow_save2();
                    break;
                case "SelectFollow":
                    p_housingFollow_list_table();
                    break;
                case "del":
                    p_housingFollow_delete();
                    break;
                case "ShowAlert":
                    p_housingAlert_list_table();
                    break;
                case "ShowInfo":
                    p_housingInform_list_table();
                    break;
                case "UpdateInfo":
                    p_housingInform_update();
                    break;
                case "UpdateAlert":
                    p_housingAlert_update();
                    break;
                case "delAlert":
                    p_housingAlert_delete();
                    break;
                case "DeleteHousing":
                    DeleteHousing();
                    break;
                case "DelPic":
                    DelPic();
                    break;
                case "tellog_list":
                    TellogList();
                    break;
                case "housingpic_list":
                    p_huosing_pic_listall_table();
                    break;
                case "estatepic_list":
                    p_estate_pic_listall_table();
                    break;
                case "SALerts":
                    SelectALerts();
                    break;
                case "UpdateMark4":                    UpdateMark4();
                    break;
                case "p_housingKey_insert":
                    p_housingKey_Save();
                    break;
                case "p_housingKey_list_table":
                    p_housingKey_list_table();
                    break;
                case "p_housingInform_updateisValid":
                    p_housingInform_updateisValid();
                    break;
                case "UpdateResult":
                    p_housingInform_updateisResult();
                    break;
                case "SelectResultList":
                    p_housingInform_ResultList_table();
                    break;
                case "UpdateHousingIsvalid":
                    p_housing_updateisValid();
                    break;
                case "p_HosingPic_insert":
                    p_HosingPic_insert();
                    break;
                case "p_housingInform_save":
                    p_housingInform_save();
                    break;
                case "GetOption":
                    GetOption();
                    break;
                case "p_housingAlert_save":
                    p_housingAlert_save();
                    break;
                case "p_ReportFollow_list":
                    p_housingFollowReport_list_table();
                    break;
                case "p_housing_Key_Report_list_table":
                    p_housing_Key_Report_list_table();
                    break;
                case "HousingListByUserId":
                    HousingListByUserId();
                    break;
                case "UpdateStatus":
                    UpdateStatus();
                    break;
                case "p_housingRecycleList":
                    p_housingRecycleList();
                    break;
                case "UpdateDltFlag":
                    UpdateDltFlag();
                    break;
                case "registerkey":
                    RegisterKey();
                    break;


                #region 房源匹配

                case "housing_match":
                    HousingMatch();
                    break;

                #endregion

                #region 我的盘源 桌面
                case "DeskMyHousing":
                    MyHousing();
                    break;

                #endregion

                #region 每日一盘

                case "housing_everyday_add":
                    HousingEverydayAdd();
                    break;
                case "housing_everyday_list":
                    HousingEverydayList();
                    break;
                case "sql_housing_everyday_list":
                    sql_HousingEverydayList();
                    break;
                case "housing_everyday_del":
                    HousingEverydayDel();
                    break;

                #endregion

                #region  笋盘推荐

                case "InsertHousingEveryDay":
                    InsertHousingEveryDay();
                    break;

                #endregion

                #region 降价盘查询

                case "housingReduction_list":
                    HousingReductionList();                             break;

                #endregion

                #region 成交盘查询

                case "housingTranction_list":
                    HousingTranctionList();                             break;
                case "housingTranction_detail":
                    HousingTranctionDetail();                             break;

                #endregion

                #region
                case "t_roomno_list_bytradetype":                    t_roomnolist();
                    break;
                case "t_roomno_list_ss":
                    t_roomno_list_ss();
                    break;
                #endregion
            }
        }

        private static void t_roomno_list_ss()
        {
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            string type = _Request.GetString("type", "0");
            string roomnoid = _Request.GetString("roomnoid", "0");

            int eid = _Request.GetInt("eid", 0);
            string json = ZLDC.Topo.BLL.Estate.RoomNoBLL.p_v_roomno_ss(roomnoid, eid, type);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }
        private static void t_roomnolist()
        {

            int page = _Request.GetInt("page", 0);
            int pagesize = 50;
            string bname = _Request.GetString("bname", "");
            string isVsild = _Request.GetString("isVsild", "");
            string roomnoid = _Request.GetString("did", "0");

            int eid = _Request.GetInt("eid", 0);
            string condition = " where delFlag=0 and eid=" + eid;
            if (!string.IsNullOrEmpty(bname) && bname != "请选择")
            {
                condition += " and finalName='" + bname + "'";
            }
            if (!string.IsNullOrEmpty(isVsild) && isVsild != "100")
            {
                condition += " and isValid=" + isVsild;
            }
            string json = ZLDC.Topo.BLL.Estate.RoomNoBLL.p_v_roomno_list_table(page, pagesize, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();

        }
        private static void RegisterKey()
        {
            int housingId = _Request.GetInt("hid", 0);            string keyNo = _Request.GetString("keyno", "");
            string keepKey = _Request.GetString("keepKey", "");
            string keepkeyDate = _Request.GetString("keepKeyDate", "");
            int count = ZLDC.Topo.BLL.Estate.HousingBLL.UpdateKeys(housingId, 1, keyNo, keepKey, keepkeyDate);
            string outmsg = "收钥匙失败!";
            if (count > 0)
            {
                outmsg = "收钥匙成功!钥匙编号:" + keyNo + ";钥匙所有人:" + keepKey;

                                ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, housingId, "添加钥匙", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID), _Utility.GetInfoBySession().m_sUserName, "钥匙编号:" + keyNo + ",钥匙所有人:" + keepKey, 0, "");

                                if (housingId > 0)
                {
                    _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + housingId.ToString());
                    _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + housingId.ToString());
                }
                                quantificationBLL.UpdateHousingQuantificationByUserName(housingId, 1, 0, 0, keepKey, "", "");

            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();

        }

        #region 盘源管理

        private static void MyHousing()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptid = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID, 0);              string allchildrenDept = _Utility.GetInfoBySession().m_sChildrenDeptList;
            string station = _Utility.GetInfoBySession().m_sStation;                
            string condition = " status=1 ";
                                                if (station.Contains("分行经理"))
                condition += " and markudeptid = (" + allchildrenDept + ")";
            else
                condition += " and markUId =" + userid;
            string json = ZLDC.Topo.BLL.Estate.HousingBLL.SelectMyHousing(5, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingSave()
        {
            int id = _Request.GetIntForm("hID", 0);
            string ename = _Request.GetStringForm("iEstateName", "");            int dId = _Request.GetIntForm("dname", 0);            string dname = _Request.GetStringForm("dname1", "");            int aId = _Request.GetIntForm("area", 0);            string area = _Request.GetStringForm("area1", "");            string buildName1 = _Request.GetStringForm("bname1", "");            string buildName2 = _Request.GetStringForm("bname2", "");
            string buildName3 = _Request.GetStringForm("bname3", "");

            int buildId1 = _Request.GetIntForm("bid1", 0);            int buildId2 = _Request.GetIntForm("bid2", 0);
            int buildId3 = _Request.GetIntForm("bid3", 0);

            string buildName = _Request.GetStringForm("iBuildList", "");
            int buildId = _Request.GetIntForm("buildName1", 0);            int level = _Request.GetIntForm("level", 0);
            buildId1 = level;

            if (buildName2.Trim() != "")
            {
                buildId = _Request.GetIntForm("buildName2", 0);
            }
            if (buildName3.Trim() != "")
            {
                buildId = _Request.GetIntForm("buildName3", 0);
            }
            string floor = _Request.GetStringForm("floor", "");            string roomNo = _Request.GetStringForm("roomNo", "");            int roomId = _Request.GetIntForm("roomid", 0);            int tradeType = _Request.GetIntForm("tradeType", 0);            int room = _Request.GetIntForm("room", 0);            int hall = _Request.GetIntForm("hall", 0);            int restroom = _Request.GetIntForm("restroom", 0);            int balcony = _Request.GetIntForm("balcony", 0);            int kitchen = _Request.GetIntForm("kitchen", 0);            float acreage = _Request.GetFloatForm("acreage", 0);            float totalprice = _Request.GetFloatForm("totalprice", 0);            float leaseprice = float.Parse(_Request.GetFloatForm("leaseprice", 0).ToString());
            float unitprice = _Request.GetFloatForm("unitprice", 0);            string owner = _Request.GetStringForm("owner", "");            string ownerTel = _Request.GetStringForm("ownerTel", "");            string linkman = _Request.GetStringForm("linkman", "");            string linkmanTel = _Request.GetStringForm("linkmanTel", "");            float costprice = _Request.GetFloatForm("costprice", 0);            string source = _Request.GetStringForm("source", "");            if (source == "请选择")
            {
                source = "";
            }
            string pocNo = _Request.GetStringForm("pocNo", "");            string pocStatus = _Request.GetStringForm("pocStatus", "");            if (pocStatus == "请选择")
            {
                pocStatus = "";
            }
            int redeem = _Request.GetIntForm("redeem1", 0);            string useStatus = _Request.GetStringForm("useStatus", "");            if (useStatus == "请选择")
            {
                useStatus = "";
            }
            string propertyRight = _Request.GetStringForm("propertyRight", "");            if (propertyRight == "请选择")
            {
                propertyRight = "";
            }
            string direct = _Request.GetStringForm("direct", "");            if (direct == "请选择")
            {
                direct = "";
            }
            string fitment = _Request.GetStringForm("fitment", "");            if (fitment == "请选择")
            {
                fitment = "";
            }
            string houseStyle = _Request.GetStringForm("houseStyle", "");            if (houseStyle == "请选择")
            {
                houseStyle = "";
            }
            int use = _Request.GetIntForm("use", 0);            string houseType = _Request.GetStringForm("houseType", "");            int hasKey = _Request.GetIntForm("hasKey1", 0);            string keyNo = _Request.GetStringForm("keyNo", "");            string keepKey = _Request.GetStringForm("keepKey", "");
            if (keepKey != "")
            {
                string userName = string.Empty;                 string userNo = string.Empty;                   _Utility.GetUserNoAndUserName(keepKey.Trim(), out userName, out userNo);
                ZLDC.Topo.Model.Estate.UserInfo user = UserBLL.GetUserInfoByUserNo(userNo);

            }

            string keepkeyDate = _Request.GetStringForm("keepkeyDate", null);            int ctyCont = _Request.GetIntForm("ctyCont1", 0);            string ctyContUser = _Request.GetStringForm("ctyContUser", "");            string ctyContDate = _Request.GetStringForm("ctyContDate", null);            string ctyEndDate = _Request.GetStringForm("ctyEndDate", null);
            int isOnly = _Request.GetIntForm("isOnly1", 0);            string OnlyUser = _Request.GetStringForm("OnlyUser", "");            string OnlyDate = _Request.GetStringForm("OnlyDate", null);            string EndDate = _Request.GetStringForm("EndDate", null);
            int markUId = _Request.GetIntForm("markUId1", 0);            string markUser = _Request.GetStringForm("markUser1", "");
            int markUDeptId = _Request.GetIntForm("markUDeptId1", 0);
            string markUDept = _Request.GetStringForm("markUDept1", "");
            string remark = _Request.GetStringForm("remark", "");            string tenant = _Request.GetStringForm("tenant", "");            float assignmentfee = _Request.GetFloatForm("assignmentfee", 0);            int addUId = _Request.GetIntForm("addUId1", 0);            string addUser = _Request.GetStringForm("addUser1", "");
            string addUDept = _Request.GetStringForm("addUDept1", "");
            int addUDeptId = _Request.GetIntForm("addUDeptId1", 0);
            string addUBank = _Request.GetStringForm("addUBankId1", "");            int Protected = _Request.GetIntForm("Protected", 0);            int clickCount = _Request.GetIntForm("clickCount", 0);            int uClick = _Request.GetIntForm("uClick", 0);            int mngClick = _Request.GetIntForm("mngClick", 0);
            string hAppliances = _Request.GetStringForm("hAppliances1", "");            string mark1 = floor;            string mark2 = _Request.GetStringForm("mark2");            if (mark2 == "请选择")
            {
                mark2 = "";
            }
            string mark3 = _Request.GetStringForm("leaseYear");            string mark4 = "";
            string mark5 = "";
            int status = _Request.GetIntForm("status", 0);
            int status1 = _Request.GetIntForm("status1", 0);
            string modifyUser = _Utility.GetInfoBySession().m_sUserName;
            int dltFlag = _Request.GetIntForm("dltFlag", 0);
            int isValid = _Request.GetIntForm("isValid", 1);            if (_Utility.GetInfoBySession().m_sRoleID == "1")             {
                isValid = 0;
            }

            int recommend = _Request.GetIntForm("recommend", 0);
            int hasPhoto = _Request.GetIntForm("hasPhoto", 0);
            DataSet dsStart = null;            DataTable dt = null;
            string CnameList = "";
            string strInfo = "";

            int isAdd = 0;
            if (id == 0)
            {
                isAdd = 1;
            }
            HousingInfo info = null;
            if (id > 0)
            {

                info = HousingBLL.p_housing_detail(id);

                if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改全部盘源") == false)                 {
                    if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改本部盘源") == false)
                    {
                        if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改本人盘源") == false)
                        {
                            NewMethod(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, EndDate, ctyContDate, ref dsStart, ref CnameList, ref strInfo);

                            return;
                        }
                        else
                        {
                                                        if (markUId.ToString() != _Utility.GetInfoBySession().m_sUserID.ToString())
                            {
                                NewMethod(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, EndDate, ctyContDate, ref dsStart, ref CnameList, ref strInfo);
                                return;

                            }

                        }
                    }
                    else
                    {
                        if (markUDeptId.ToString() != _Utility.GetInfoBySession().m_sDeptID.ToString())                         {
                            NewMethod(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, EndDate, ctyContDate, ref dsStart, ref CnameList, ref strInfo);

                            return;
                        }
                    }

                }
            }

            if (id > 0)
            {

                string cachekey = "updateHousingFileName";                string cachekeyTable = "housingDataTable";
                if (_Cache.GetCache(cachekey) == null || _Cache.GetCache(cachekey).ToString() == "")
                {
                    dt = ZLDC.Topo.BLL.Estate.T_SYS_COL_BLL.p_sys_col_detail_table("t_housing", 1);                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        CnameList += dt.Rows[i]["cName"] + ",";
                    }
                    if (CnameList.Length > 0)
                    {
                        CnameList = CnameList.Substring(0, CnameList.Length - 1);
                    }

                    if (CnameList != "")
                    {
                        _Cache.SetCache(cachekey, CnameList, 3600 * 1);
                        _Cache.SetCache(cachekeyTable, dt, 3600 * 1);
                    }
                }
                else
                {
                    CnameList = _Cache.GetCache(cachekey).ToString();
                    dt = _Cache.GetCache(cachekeyTable) as DataTable;
                }


                dsStart = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(id, CnameList);
            }
            string outmsg = "";

                        outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_save(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, buildId1, buildId2, buildId3, EndDate, ctyEndDate);

            if (id > 0)            {
                DataSet ds = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(id, CnameList);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string colName = dt.Rows[i]["ccmmt"].ToString();
                    string BeForName = dsStart.Tables[0].Rows[0][i].ToString();                    string sAfter = ds.Tables[0].Rows[0][i].ToString();                    if (colName == "业主电话" || colName == "联系人电话")
                    {
                        if (BeForName != sAfter)
                        {
                            strInfo += "修改:" + colName + ",原电话[" + BeForName + "]；";
                        }
                    }
                    else if (colName == "是否有钥匙" || colName == "是否独家" || colName == "是否反签")
                    {
                        if (BeForName != sAfter)
                        {
                            if (BeForName == "0" && sAfter == "1")
                            {
                                strInfo += colName + ":" + "否" + "->" + "是" + "; ";
                            }
                            else if (BeForName == "1" && sAfter == "0")
                            {
                                strInfo += colName + ":" + "是" + "->" + "否" + "; ";
                            }
                        }
                    }
                    #region  钥匙，独家发生改变时，记录原钥匙，独家人员信息
                    else if (colName == "收钥匙人" || colName == "独家人员")
                    {
                        if (BeForName != sAfter)
                        {
                            strInfo += colName + ":" + BeForName + "->" + sAfter + ";";
                        }



                        if (colName == "收钥匙人")
                        {
                            if (BeForName != "")
                            {
                                string keyUser = dsStart.Tables[0].Rows[0][i].ToString();

                                if (keyUser != "")
                                {
                                    string userName = string.Empty;                                     string userNo = string.Empty;                                       int userId = 0;                                                     _Utility.GetUserNoAndUserName(keyUser.Trim(), out userName, out userNo);
                                    userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(userNo);

                                    ZLDC.Topo.BLL.Estate.HousingBLL.KeyorExclusiveSave(id, userId, userName, 1);
                                }

                            }
                        }
                        else if (colName == "独家人员")
                        {
                            if (BeForName != "")
                            {
                                string OnlyUserName = dsStart.Tables[0].Rows[0][i].ToString();

                                if (OnlyUserName != "")
                                {
                                    string userName = string.Empty;                                     string userNo = string.Empty;                                       int userId = 0;                                                     _Utility.GetUserNoAndUserName(OnlyUserName.Trim(), out userName, out userNo);
                                    userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(userNo);

                                    ZLDC.Topo.BLL.Estate.HousingBLL.KeyorExclusiveSave(id, userId, userName, 2);
                                }

                            }
                        }

                    }
                    #endregion
                    else if (colName == "房屋设施" && use == 1)                    {
                        string happliances = "装修,暖气,电话,电视,空调,电风扇,洗衣机,热水器,煤气灶,抽油烟机,电冰箱,微波炉,床,衣柜,书柜,厨柜,沙发,茶几,宽带,电梯,停车位,露台";
                        string[] arr = happliances.Split(',');
                        string[] arr1;
                        if (BeForName.ToString() == "")
                        {
                            string str = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
                            arr1 = str.Split(',');
                        }
                        else
                        {
                            arr1 = BeForName.Split(',');
                        }
                        string[] arr2 = sAfter.Split(',');
                        string strHL = "";
                        string strHL1 = "";
                        for (int j = 0; j < arr.Length; j++)
                        {
                            if (arr2.Length == arr.Length)
                            {
                                if (arr1[j] == "0" && arr2[j] == "1")
                                {
                                    strHL = colName + ":";
                                    strHL1 += arr[j];
                                    if (j < arr.Length - 1)
                                    {
                                        strHL1 += ",";
                                    }
                                }
                                else if (arr1[j] == "1" && arr2[j] == "0")
                                {
                                    strHL = colName + ":";
                                    strHL1 += arr[j];
                                    if (j < arr.Length - 1)
                                    {
                                        strHL1 += ",";
                                    }

                                }
                            }
                        }
                        if (strHL1 != "" || strHL != "")
                        {
                            strInfo += strHL + strHL1;
                        }
                    }
                    else if (colName != "收钥匙人部门")
                    {
                        if (BeForName != sAfter)
                        {
                            strInfo += colName + ":" + BeForName + "->" + sAfter + "; ";
                        }
                    }
                }
                if (strInfo != "")
                {
                                        ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, id, "盘源修改", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID), _Utility.GetInfoBySession().m_sUserName, strInfo, 0, "");
                }

                if (outmsg.Equals("更新成功"))
                {
                                        if (info.KeepKey != keepKey)
                    {
                        quantificationBLL.UpdateHousingQuantificationByUserName(id, hasKey, 0, 0, keepKey, "", "");
                    }

                    if (info.IsOnly != isOnly)
                    {
                        quantificationBLL.UpdateHousingQuantificationByUserName(id, 0, isOnly, 0, "", OnlyUser, "");

                    }

                    if (info.CtyContUser != ctyContUser)
                    {
                        quantificationBLL.UpdateHousingQuantificationByUserName(id, 0, 0, ctyCont, "", "", ctyContUser);

                    }


                                                        }
            }

                        if (id > 0)
            {
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
            }

            if (outmsg.Equals("添加成功") || outmsg.Equals("更新成功"))
            {


                System.Web.HttpContext.Current.Response.Redirect("../ErrorHousing.aspx?errormsg=" + System.Web.HttpUtility.UrlEncode(outmsg));
            }
            else
            {

                _Utility.GoError(outmsg);
            }

        }

                                private static void ChangeHousingSave()
        {
            int id = _Request.GetIntForm("hID", 0);
            string ename = _Request.GetStringForm("iEstateName", "");            int dId = _Request.GetIntForm("dname", 0);            string dname = _Request.GetStringForm("dname1", "");            int aId = _Request.GetIntForm("area", 0);            string area = _Request.GetStringForm("area1", "");
            int buildId1 = _Request.GetIntForm("bid1", 0);            int buildId2 = _Request.GetIntForm("bid2", 0);
            int buildId3 = _Request.GetIntForm("bid3", 0);

            string buildName = _Request.GetStringForm("iBuildList", "");
            int buildId = _Request.GetIntForm("buildName1", 0);            int level = _Request.GetIntForm("level", 0);
            buildId1 = level;


            string floor = _Request.GetStringForm("floor", "");            string roomNo = _Request.GetStringForm("roomNo", "");            int roomId = _Request.GetIntForm("roomid", 0);            int tradeType = _Request.GetIntForm("tradeType", 0);            int room = _Request.GetIntForm("room", 0);            int hall = _Request.GetIntForm("hall", 0);            int restroom = _Request.GetIntForm("restroom", 0);            int balcony = _Request.GetIntForm("balcony", 0);            int kitchen = _Request.GetIntForm("kitchen", 0);            float acreage = _Request.GetFloatForm("acreage", 0);            float totalprice = _Request.GetFloatForm("totalprice", 0);
            float leaseprice = _Request.GetFloatForm("leaseprice", 0);            float unitprice = _Request.GetFloatForm("unitprice", 0);            string owner = _Request.GetStringForm("owner", "");            string ownerTel = _Request.GetStringForm("ownerTel", "");            string linkman = _Request.GetStringForm("linkman", "");            string linkmanTel = _Request.GetStringForm("linkmanTel", "");            float costprice = _Request.GetFloatForm("costprice", 0);            string source = _Request.GetStringForm("source", "");            if (source == "请选择")
            {
                source = "";
            }
            string pocNo = _Request.GetStringForm("pocNo", "");            string pocStatus = _Request.GetStringForm("pocStatus", "");            if (pocStatus == "请选择")
            {
                pocStatus = "";
            }
            int redeem = _Request.GetIntForm("redeem1", 0);            string useStatus = _Request.GetStringForm("useStatus", "");            if (useStatus == "请选择")
            {
                useStatus = "";
            }
            string propertyRight = _Request.GetStringForm("propertyRight", "");            if (propertyRight == "请选择")
            {
                propertyRight = "";
            }
            string direct = _Request.GetStringForm("direct", "");            if (direct == "请选择")
            {
                direct = "";
            }
            string fitment = _Request.GetStringForm("fitment", "");            if (fitment == "请选择")
            {
                fitment = "";
            }
            string houseStyle = _Request.GetStringForm("houseStyle", "");            if (houseStyle == "请选择")
            {
                houseStyle = "";
            }
            int use = _Request.GetIntForm("use", 0);            string houseType = _Request.GetStringForm("houseType", "");            int hasKey = _Request.GetIntForm("hasKey1", 0);            string keyNo = _Request.GetStringForm("keyNo", "");            string keepKey = _Request.GetStringForm("keepKey", "");            if (keepKey != "")
            {
                string userName = string.Empty;                 string userNo = string.Empty;                   _Utility.GetUserNoAndUserName(keepKey.Trim(), out userName, out userNo);


            }

            string keepkeyDate = _Request.GetStringForm("keepkeyDate", null);            int ctyCont = _Request.GetIntForm("ctyCont1", 0);            string ctyContUser = _Request.GetStringForm("ctyContUser", "");            string ctyContDate = _Request.GetStringForm("ctyContDate", null);            string ctyEndDate = _Request.GetStringForm("ctyEndDate", null);
            int isOnly = _Request.GetIntForm("isOnly1", 0);            string OnlyUser = _Request.GetStringForm("OnlyUser", "");            string OnlyDate = _Request.GetStringForm("OnlyDate", null);            string EndDate = _Request.GetStringForm("EndDate", null);
            int markUId = 0;            string markUser = "";
            int markUDeptId = 0;
            string markUDept = "";

            if (id > 0)            {
                markUId = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);                markUser = _Utility.GetInfoBySession().m_sUserName;
                markUDeptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
                markUDept = _Utility.GetInfoBySession().m_sDeptName;
            }
            else
            {
                markUId = _Request.GetIntForm("markUId1", 0);                markUser = _Request.GetStringForm("markUser1", "");
                markUDeptId = _Request.GetIntForm("markUDeptId1", 0);
                markUDept = _Request.GetStringForm("markUDept1", "");
            }
            string remark = _Request.GetStringForm("remark", "");            string tenant = _Request.GetStringForm("tenant", "");            float assignmentfee = _Request.GetFloatForm("assignmentfee", 0);            int addUId = _Request.GetIntForm("addUId1", 0);            string addUser = _Request.GetStringForm("addUser1", "");
            string addUDept = _Request.GetStringForm("addUDept1", "");
            int addUDeptId = _Request.GetIntForm("addUDeptId1", 0);
            string addUBank = _Request.GetStringForm("addUBankId1", "");            int Protected = _Request.GetIntForm("Protected", 0);            int clickCount = _Request.GetIntForm("clickCount", 0);            int uClick = _Request.GetIntForm("uClick", 0);            int mngClick = _Request.GetIntForm("mngClick", 0);
            string hAppliances = _Request.GetStringForm("hAppliances1", "");            string mark1 = floor;            string mark2 = _Request.GetStringForm("mark2");            if (mark2 == "请选择")
            {
                mark2 = "";
            }
            string mark3 = _Request.GetStringForm("leaseYear");            string mark4 = "";
            string mark5 = "";
            int status = _Request.GetIntForm("status", 0);
            int status1 = _Request.GetIntForm("status1", 0);
            string modifyUser = _Utility.GetInfoBySession().m_sUserName;
            int dltFlag = _Request.GetIntForm("dltFlag", 0);

            int isValid = _Request.GetIntForm("isValid", 1);            if (id > 0)
            {
                isValid = 1;
            }
            int recommend = _Request.GetIntForm("recommend", 0);
            int hasPhoto = _Request.GetIntForm("hasPhoto", 0);
            DataSet dsStart = null;            DataTable dt = null;
            string CnameList = "";
            string strInfo = "";

            int isAdd = 0;
            if (id == 0)
            {
                isAdd = 1;
            }
            if (id > 0)
            {

                if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改全部盘源") == false)                 {
                    if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改本部盘源") == false)
                    {
                        if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("修改本人盘源") == false)
                        {
                            NewMethod(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, EndDate, ctyEndDate, ref dsStart, ref CnameList, ref strInfo);

                            return;
                        }
                        else
                        {
                                                        if (markUId.ToString() != _Utility.GetInfoBySession().m_sUserID.ToString())
                            {
                                NewMethod(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, EndDate, ctyEndDate, ref dsStart, ref CnameList, ref strInfo);
                                return;

                            }

                        }
                    }
                    else
                    {
                        if (markUDeptId.ToString() != _Utility.GetInfoBySession().m_sDeptID.ToString())                         {
                            NewMethod(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, EndDate, ctyEndDate, ref dsStart, ref CnameList, ref strInfo);

                            return;
                        }
                    }

                }
            }

            if (id > 0)
            {

                string cachekey = "updateHousingFileName";                string cachekeyTable = "housingDataTable";
                if (_Cache.GetCache(cachekey) == null || _Cache.GetCache(cachekey).ToString() == "")
                {
                    dt = ZLDC.Topo.BLL.Estate.T_SYS_COL_BLL.p_sys_col_detail_table("t_housing", 1);                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        CnameList += dt.Rows[i]["cName"] + ",";
                    }
                    if (CnameList.Length > 0)
                    {
                        CnameList = CnameList.Substring(0, CnameList.Length - 1);
                    }

                    if (CnameList != "")
                    {
                        _Cache.SetCache(cachekey, CnameList, 3600 * 1);
                        _Cache.SetCache(cachekeyTable, dt, 3600 * 1);
                    }
                }
                else
                {
                    CnameList = _Cache.GetCache(cachekey).ToString();
                    dt = _Cache.GetCache(cachekeyTable) as DataTable;
                }


                dsStart = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(id, CnameList);
            }
            string outmsg = "";

                        outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.p_changehousing_save(id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepkeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, buildId1, buildId2, buildId3, EndDate, ctyEndDate);

            if (id > 0)            {
                DataSet ds = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(id, CnameList);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string colName = dt.Rows[i]["ccmmt"].ToString();
                    string BeForName = dsStart.Tables[0].Rows[0][i].ToString();                    string sAfter = ds.Tables[0].Rows[0][i].ToString();                    if (colName == "业主电话" || colName == "联系人电话")
                    {
                        if (BeForName != sAfter)
                        {
                            strInfo += "修改:" + colName + ",原电话[" + BeForName + "]；";
                        }
                    }
                    else if (colName == "是否有钥匙" || colName == "是否独家" || colName == "是否反签")
                    {
                        if (BeForName != sAfter)
                        {
                            if (BeForName == "0" && sAfter == "1")
                            {
                                strInfo += colName + ":" + "否" + "->" + "是" + "; ";
                            }
                            else if (BeForName == "1" && sAfter == "0")
                            {
                                strInfo += colName + ":" + "是" + "->" + "否" + "; ";
                            }
                        }
                    }
                    else if (colName == "房屋设施" && use == 1)                    {
                        string happliances = "装修,暖气,电话,电视,空调,电风扇,洗衣机,热水器,煤气灶,抽油烟机,电冰箱,微波炉,床,衣柜,书柜,厨柜,沙发,茶几,宽带,电梯,停车位,露台";
                        string[] arr = happliances.Split(',');
                        string[] arr1;
                        if (BeForName.ToString() == "")
                        {
                            string str = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
                            arr1 = str.Split(',');
                        }
                        else
                        {
                            arr1 = BeForName.Split(',');
                        }
                        string[] arr2 = sAfter.Split(',');
                        string strHL = "";
                        string strHL1 = "";
                        for (int j = 0; j < arr.Length; j++)
                        {
                            if (arr1[j] == "0" && arr2[j] == "1")
                            {
                                strHL = colName + ":";
                                strHL1 += arr[j];
                                if (j < arr.Length - 1)
                                {
                                    strHL1 += ",";
                                }
                            }
                            else if (arr1[j] == "1" && arr2[j] == "0")
                            {
                                strHL = colName + ":";
                                strHL1 += arr[j];
                                if (j < arr.Length - 1)
                                {
                                    strHL1 += ",";
                                }

                            }
                        }
                        if (strHL1 != "" || strHL != "")
                        {
                            strInfo += strHL + strHL1;
                        }
                    }
                    else if (colName != "收钥匙人部门")
                    {
                        if (BeForName != sAfter)
                        {
                            strInfo += colName + ":" + BeForName + "->" + sAfter + "; ";
                        }
                    }
                }
                if (strInfo != "")
                {
                                        ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, id, "盘源修改", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID), _Utility.GetInfoBySession().m_sUserName, strInfo, 0, "");
                }

                if (outmsg.Equals("更新成功"))
                {
                    quantificationBLL.UpdateHousingQuantificationByUserName(id, hasKey, isOnly, ctyCont, keepKey, OnlyUser, ctyContUser);
                }
            }

                        if (id > 0)
            {

                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
            }

            if (outmsg.Equals("添加成功") || outmsg.Equals("更新成功"))
            {
                System.Web.HttpContext.Current.Response.Redirect("../ErrorHousing.aspx?errormsg=" + System.Web.HttpUtility.UrlEncode(outmsg));
            }
            else
            {

                _Utility.GoError(outmsg);
            }

        }

                        private static void NewMethod(int Id, int dId, string dname, int aId, string area, string buildName, int buildId, string roomNo, int roomId, int tradeType, int room, int hall, int restroom, int balcony, int kitchen, float acreage, float totalprice, float leaseprice, float unitprice, string owner, string ownerTel, string linkman, string linkmanTel, float costprice, string source, string pocNo, string pocStatus, int redeem, string useStatus, string propertyRight, string direct, string fitment, string houseStyle, int use, string houseType, int hasKey, string keyNo, string keepKey, string keepKeyDate, int ctyCont, string ctyContUser, string ctyContDate, int isOnly, string OnlyUser, string OnlyDate, int markUId, string markUser, int markUDeptId, string markUDept, string remark, string tenant, float assignmentfee, int addUId, string addUser, string addUDept, int addUDeptId, string addUBank, int Protected, int clickCount, string hAppliances, string mark1, string mark2, string mark3, string mark4, string mark5, int status, int status1, string modifyUser, int dltFlag, int isValid, int recommend, int hasPhoto, string endDate, string ctyEndDate, ref DataSet dsStart, ref string CnameList, ref string strInfo)
        {
            DataSet ds = null;
            HousingInfo info = HousingBLL.p_housing_detail(Id);

            if (info.Status == 2 && info.Status1 == 0 && info.IsValid == 0)            {
                string cachekey = "updateHousingFileNameBymark";
                string cachekey1 = "DSHousing";

                if (_Cache.GetCache(cachekey) == null || _Cache.GetCache(cachekey).ToString() == "")
                {
                    ds = ZLDC.Topo.BLL.Estate.T_SYS_COL_BLL.p_sys_col_list_table(" where tname='t_housing' and mark1 in(1,2,3) ");
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        CnameList += ds.Tables[0].Rows[i]["cName"].ToString() + ",";

                    }
                    if (CnameList.Length > 0)
                    {
                        CnameList = CnameList.Substring(0, CnameList.Length - 1);
                    }

                    if (CnameList != "")
                    {
                        _Cache.SetCache(cachekey, CnameList, 3600 * 1);
                        _Cache.SetCache(cachekey1, ds, 3600 * 1);
                    }
                }
                else
                {
                    CnameList = _Cache.GetCache(cachekey).ToString();
                    ds = _Cache.GetCache(cachekey1) as DataSet;
                }
            }
            else
            {
                string cachekey = "updateHousingFileNameBymark1";
                string cachekey1 = "DSHousing1";
                if (info.KeepKey == "" && info.KeepKeyDate == "" && info.KeyNo == "")
                {
                    cachekey = "updateHousingFileNameBymark2";
                    cachekey1 = "DSHousing2";
                }

                if (_Cache.GetCache(cachekey) == null || _Cache.GetCache(cachekey).ToString() == "")
                {
                    string station = _Utility.GetInfoBySession().m_sStation;                                        if (info.MarkUId.ToString() == _Utility.GetInfoBySession().m_sUserID || (info.MarkUDeptId.ToString() == _Utility.GetInfoBySession().m_sDeptID && _Utility.GetInfoBySession().m_sStation == "分行经理") || cachekey == "updateHousingFileNameBymark2" || _Utility.GetWebConfigSetting("SalesManagerStation").Contains(station))
                        ds = ZLDC.Topo.BLL.Estate.T_SYS_COL_BLL.p_sys_col_list_table(" where tname='t_housing' and mark1 in(1,3) ");                    else
                        ds = ZLDC.Topo.BLL.Estate.T_SYS_COL_BLL.p_sys_col_list_table(" where tname='t_housing' and mark1=1  ");

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        CnameList += ds.Tables[0].Rows[i]["cName"].ToString() + ",";

                    }
                    if (CnameList.Length > 0)
                    {
                        CnameList = CnameList.Substring(0, CnameList.Length - 1);
                    }

                    if (CnameList != "")
                    {
                        _Cache.SetCache(cachekey, CnameList, 3600 * 1);
                        _Cache.SetCache(cachekey1, ds, 3600 * 1);
                    }
                }
                else
                {
                    CnameList = _Cache.GetCache(cachekey).ToString();
                    ds = _Cache.GetCache(cachekey1) as DataSet;
                }
            }

            dsStart = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(Id, CnameList);                        
            int count = ZLDC.Topo.BLL.Estate.HousingBLL.UpdateFileds(ds, Id, dId, dname, aId, area, buildName, buildId, roomNo, roomId, tradeType, room, hall, restroom, balcony, kitchen, acreage, totalprice, leaseprice, unitprice, owner, ownerTel, linkman, linkmanTel, costprice, source, pocNo, pocStatus, redeem, useStatus, propertyRight, direct, fitment, houseStyle, use, houseType, hasKey, keyNo, keepKey, keepKeyDate, ctyCont, ctyContUser, ctyContDate, isOnly, OnlyUser, OnlyDate, markUId, markUser, markUDeptId, markUDept, remark, tenant, assignmentfee, addUId, addUser, addUDept, addUDeptId, addUBank, Protected, clickCount, hAppliances, mark1, mark2, mark3, mark4, mark5, status, status1, modifyUser, dltFlag, isValid, recommend, hasPhoto, endDate, ctyEndDate);
            string outmsg = "修改失败";


            if (count > 0)
            {
                DataSet dsbefore = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(Id, CnameList);                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string colName = ds.Tables[0].Rows[i]["ccmmt"].ToString();

                    string BeForName = dsStart.Tables[0].Rows[0][i].ToString();                    string sAfter = dsbefore.Tables[0].Rows[0][i].ToString();
                    if (BeForName != sAfter)                    {
                        if (colName == "业主电话" || colName == "联系人电话")
                        {
                            strInfo += "修改:" + colName + ",原电话[" + BeForName + "]；";
                        }
                        else if (colName == "是否赎楼" || colName == "是否有钥匙" || colName == "是否独家" || colName == "是否限时")
                        {
                            if (BeForName == "0")
                                BeForName = "否";
                            if (sAfter == "1")
                                sAfter = "是";

                            strInfo += colName + ":" + BeForName + "->" + sAfter + ";";

                        }
                        else if (colName == "收钥匙人" || colName == "独家人员")
                        {
                            strInfo += colName + ":" + BeForName + "->" + sAfter + ";";


                            #region  钥匙，独家发生改变时，记录原钥匙，独家人员信息

                            if (colName == "收钥匙人")
                            {
                                if (BeForName != "")
                                {
                                    string keyUser = dsStart.Tables[0].Rows[0][i].ToString();

                                    if (keyUser != "")
                                    {
                                        string userName = string.Empty;                                         string userNo = string.Empty;                                           int userId = 0;                                                         _Utility.GetUserNoAndUserName(keyUser.Trim(), out userName, out userNo);
                                        userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(userNo);

                                        ZLDC.Topo.BLL.Estate.HousingBLL.KeyorExclusiveSave(Id, userId, userName, 1);
                                    }

                                }
                            }
                            else if (colName == "独家人员")
                            {
                                if (BeForName != "")
                                {
                                    string OnlyUserName = dsStart.Tables[0].Rows[0][i].ToString();

                                    if (OnlyUserName != "")
                                    {
                                        string userName = string.Empty;                                         string userNo = string.Empty;                                           int userId = 0;                                                         _Utility.GetUserNoAndUserName(OnlyUserName.Trim(), out userName, out userNo);
                                        userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(userNo);

                                        ZLDC.Topo.BLL.Estate.HousingBLL.KeyorExclusiveSave(Id, userId, userName, 2);
                                    }

                                }
                            }
                            #endregion
                        }
                        else if (colName != "收钥匙人部门")
                        {
                            strInfo += colName + ":" + BeForName + "->" + sAfter + ";";

                        }

                    }
                }

                if (strInfo != "")
                    ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, Id, "修改盘源", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID), _Utility.GetInfoBySession().m_sUserName, strInfo, 0, "");

                outmsg = "修改成功";


                if (info.IsValid == 0)
                {
                                        if (info.KeepKey != keepKey)
                    {
                        quantificationBLL.UpdateHousingQuantificationByUserName(Id, hasKey, 0, 0, keepKey, "", "");
                    }

                    if (info.IsOnly != isOnly)
                    {
                        quantificationBLL.UpdateHousingQuantificationByUserName(Id, 0, isOnly, 0, "", OnlyUser, "");

                    }

                    if (info.CtyContUser != ctyContUser)
                    {
                        quantificationBLL.UpdateHousingQuantificationByUserName(Id, 0, 0, ctyCont, "", "", ctyContUser);

                    }
                }
            }
                        if (Id > 0)
            {

                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + Id.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + Id.ToString());
            }

            if (outmsg.Equals("修改成功"))

                System.Web.HttpContext.Current.Response.Redirect("../ErrorHousing.aspx?errormsg=" + System.Web.HttpUtility.UrlEncode(outmsg));
            else
                _Utility.GoError(outmsg);
        }

                public static void HousingList()
        {
            string json = "";

            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                        int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);

                        string orderByName = _Request.GetString("orderByName", "markDate");
            string orderByType = _Request.GetString("orderByType", "desc");
            string city1 = _Request.GetString("city1", "0");            string city2 = _Request.GetString("city2", "0");

                                    string condition = " where dltFlag=0 and isvalid < 2";

            int mark4 = _Request.GetInt("mark4", 0);            if(mark4>0)
                condition += " and mark4=" + mark4 + "";
            

            int status = _Request.GetInt("status", 0);                                                      if (status == 1)
                condition += " and (status = 1 or (status1 > 1 and status = 2)) ";                                         else if (status == 2)
                condition += " and status=" + status;
            else if (status == 3)
                condition += " and status=" + status;

            string use = HttpContext.Current.Request["roid"] != null ? HttpContext.Current.Request["roid"].ToString() : "";
            if (!string.IsNullOrEmpty(use))
            {
                string[] a = use.Split(',');
                if (a.Length > 1)
                {
                    condition += " and [use] in (" + use + ")";
                }
                else
                {
                    condition += " and [use] = " + use;
                }

            }

            if (!string.IsNullOrEmpty(city1) && city1 != "0")
            {
                condition += " and dID=" + city1;
            }
            if (!string.IsNullOrEmpty(city2) && city2 != "0")
            {
                condition += " and aID=" + city2;
            }
                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
                else
                    condition += " and 1=2 ";                }

            int id = _Request.GetInt("id", 0);                                              if (id > 0)
            {
                condition += " and id=" + id;

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_action(userid, page, pagesize, condition, orderByName, orderByType);
                HttpContext.Current.Response.Write(json);
            }

            condition += Utility.GetHousingConditionByAdv();

            json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition, orderByName, orderByType);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingListAction()
        {
            string json = "";

            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                        int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);

                        string orderByName = _Request.GetString("orderByName", "udDate");
            string orderByType = _Request.GetString("orderByType", "desc");

            string condition = " where dltFlag=0 and isvalid < 2 ";

                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
            }

            int id = _Request.GetInt("id", 0);                                              if (id > 0)
            {
                condition += " and id=" + id;

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_action(userid, page, pagesize, condition, orderByName, orderByType);
                HttpContext.Current.Response.Write(json);
            }

            condition += Utility.GetHousingConditionByAdv();

            json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_action(userid, page, pagesize, condition, orderByName, orderByType);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingLockList()
        {
            string json = "";

            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                        int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);

                        string orderByName = _Request.GetString("orderByName", "");
            string orderByType = _Request.GetString("orderByType", "desc");
            string city1 = _Request.GetString("city1", "0");            string city2 = _Request.GetString("city2", "0");
            string condition = " where dltFlag=0 and isvalid < 2 and protected=1 ";


                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string allchildrenDept = _Utility.GetInfoBySession().m_sChildrenDeptList;
                condition += " and (protectedUid=" + userid + " or markUDeptId in (" + allchildrenDept + ")) ";                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
            }

            int id = _Request.GetInt("id", 0);                                              if (id > 0)
            {
                condition += " and id=" + id;

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition, orderByName, orderByType);
                HttpContext.Current.Response.Write(json);
            }

            string use = HttpContext.Current.Request["roid"] != null ? HttpContext.Current.Request["roid"].ToString() : "";
            if (!string.IsNullOrEmpty(use))
            {
                string[] a = use.Split(',');
                if (a.Length > 1)
                {
                    condition += " and [use] in (" + use + ")";
                }
                else
                {
                    condition += " and [use] = " + use;
                }

            }
            if (!string.IsNullOrEmpty(city1) && city1 != "0")
            {
                condition += " and dID=" + city1;
            }
            if (!string.IsNullOrEmpty(city2) && city2 != "0")
            {
                condition += " and aID=" + city2;
            }
            string usage = _Request.GetString("usage", "");                      if (usage != "" && usage != "全部" && usage != "无")
                condition += " and [use]='" + usage + "'";

            string buildName = _Request.GetString("name", "");                  if (buildName != "" && buildName != "楼盘名称、拼音均可")
            {
                string[] buildList = _Utility.GetStringBySplit(buildName, ',');
                condition += " and (";
                for (int i = 0; i < buildList.Length; i++)
                {
                    string item = buildList[i];

                    if (!item.Equals(""))
                    {
                        if (i == 0)
                            condition += " eName like '%" + item + "%'";
                        else
                            condition += " or eName like '%" + item + "%'";
                    }
                }
                condition += " )";
            }

            int room = _Request.GetInt("room", 0);                              if (room > 0)
                condition += " and room=" + room;

            int hall = _Request.GetInt("hall", 0);                              if (hall > 0)
                condition += " and hall=" + hall;

            int acreage1 = _Request.GetInt("acreage1", 0);                      int acreage2 = _Request.GetInt("acreage2", 0);                      if (acreage1 > 0)
            {
                condition += " and acreage >=" + acreage1;
            }
            if (acreage2 > 0)
            {
                condition += " and acreage <= " + acreage2;
            }

            int did = _Request.GetInt("did", 0);                                if (did > 0)
                condition += " and did=" + did;

            int aid = _Request.GetInt("aid", 0);                                if (aid > 0)
                condition += " and aid=" + aid;

            int status = _Request.GetInt("status", 0);                          if (status > 0)
                condition += " and status=" + status;

            int tradetype = _Request.GetInt("tradetype", 0);                    if (tradetype > 0)
                condition += " and tradeType=" + tradetype;

            int price1 = _Request.GetInt("price1", 0);                          int price2 = _Request.GetInt("price2", 0);                          if (price1 > 0 || price2 > 0)
            {
                if (tradetype == 1)
                    condition += " and totalprice >=" + price1 + " and totalprice < " + price2;
                else
                    condition += " and leaseprice >=" + price1 + " and leaseprice < " + price2;
            }

            int hasKey = _Request.GetInt("hasKey", 0);                              if (hasKey > 0)
                condition += " and hasKey=" + hasKey;

            int isOnly = _Request.GetInt("isOnly", 0);                              if (isOnly > 0)
                condition += " and isOnly=" + isOnly;

            int hasPhoto = _Request.GetInt("hasPhoto", 0);                          if (hasPhoto > 0)
                condition += " and hasPhoto=" + hasPhoto;

            int pocStatus = _Request.GetInt("pocStatus", 0);                        if (pocStatus > 0)
                condition += " and pocStatus='红本'";

            int mark2 = _Request.GetInt("mark2", 0);                                if (mark2 > 0)
                condition += " and mark2='满5年免税'";

                        string linkman = _Request.GetString("linkman", "");                     if (linkman != "")
                condition += " and owner='" + linkman + "'";

            string linktel = _Request.GetString("linktel", "");                     if (linktel != "")
                condition += " and ownertel='" + linktel + "'";

            int unitPrice1 = _Request.GetInt("unitPrice1", 0);                          int unitPrice2 = _Request.GetInt("unitPrice2", 0);                          if (unitPrice1 > 0 && unitPrice2 > 0)
                condition += " and unitPrice >=" + unitPrice1 + " and unitPrice < " + unitPrice1;

            string markUdept = _Request.GetString("markUdept", "");                     if (markUdept != "")
                condition += " and markUdept = '" + markUdept + "'";

            string adduser = _Request.GetString("adduser", "");                         if (adduser != "")
            {
                string userName = string.Empty;                 string userNo = string.Empty;                   int userId = 0;                                 _Utility.GetUserNoAndUserName(adduser.Trim(), out userName, out userNo);
                userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(userNo);

                condition += " and markuid = '" + userId + "'";
            }

            string fitment = _Request.GetString("fitment", "");                         if (fitment != "" && fitment != "全部")
                condition += " and fitment = '" + fitment + "'";

            string houseStyle = _Request.GetString("houseStyle", "");                   if (houseStyle != "" && houseStyle != "全部")
                condition += " and houseStyle = '" + houseStyle + "'";

            string direct = _Request.GetString("direct", "");                           if (direct != "" && direct != "全部")
                condition += " and direct = '" + direct + "'";

            string happliances = _Request.GetString("happliances", "");                     if (happliances != "")
                condition += " and happliances like '%" + happliances + "%'";

            string startdate = _Request.GetString("startdate", "");                         string enddate = _Request.GetString("enddate", "");
            if (startdate != "" && enddate != "")
                condition += " and AddDate > '" + startdate + "' and AddDate < '" + enddate + "'";

            string type = _Request.GetString("type", "");                                   if (type != "" && type != "全部" && type != "无")
                condition += " and [housetype]='" + type + "'";

            int floor1 = _Request.GetInt("floor1", 0);                                        int floor2 = _Request.GetInt("floor2", 0);                                        if (floor1 > 0 && floor2 > 0)
                condition += " and " + floor1 + " <= mark1 and mark1 <= " + floor2;
            else if (floor1 > 0)
                condition += " and mark1 = " + floor1;
            else if (floor2 > 0)
                condition += " and mark1 = " + floor2;

            string roomno = _Request.GetString("roomno", "");                   if (roomno != "")
                condition += " and roomno='" + roomno + "'";

            json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition, orderByName, orderByType);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingListByUserId()
        {
            int userid = _Request.GetInt("userid", 0);
            string condition = " where markUId=" + userid + " ";
            int housingid = _Request.GetInt("id", 0);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            string status = _Request.GetString("status", "");
            if (housingid > 0)
                condition += " and id=" + housingid + " ";

            if (status != "全部")
                condition += " and status=" + status + " ";

            string json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingRecycleList()
        {
            string condition = " where dltflag=1 ";
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            int pId = _Request.GetInt("pId", 0);
            string name = _Request.GetString("name", "");
            if (pId > 0)
                condition += " and id=" + pId + "";
            if (name != "")
                condition += " and ename='" + name + "'";

            string json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_Recycle_list_table(page, pagesize, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void DeleteHousing()
        {
            string outmsg = "";
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');

            if (IDList != null && IDList.Length > 0)
            {
                for (int i = 0; i < IDList.Length; i++)
                {
                    outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.DeleteHousing(_Convert.ToInt(IDList[i], 0));
                }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void UpdateDltFlag()
        {
            string outmsg = "";
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');

            if (IDList != null && IDList.Length > 0)
            {
                for (int i = 0; i < IDList.Length; i++)
                {
                    outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.UpdateDltFlag(_Convert.ToInt(IDList[i], 0));
                }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void HousingTypeList()
        {
            string json = "";

            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);                 int deptid = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID, 0);              string station = _Utility.GetInfoBySession().m_sStation;                            string allchildrenDept = _Utility.GetInfoBySession().m_sChildrenDeptList;
            string SalesManagerStation = _Utility.GetWebConfigSetting("SalesManagerStation");

            int typeid = _Request.GetInt("typeid", 0);                  int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);

                        string orderByName = _Request.GetString("orderByName", "markDate");
            string orderByType = _Request.GetString("orderByType", "desc");
            string city1 = _Request.GetString("city1", "0");            string city2 = _Request.GetString("city2", "0");            string condition = " where dltFlag=0 and status1!=1";

            int id = _Request.GetInt("id", 0);                                              if (id > 0)
            {
                condition += " and id=" + id;

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition, orderByName, orderByType);
                HttpContext.Current.Response.Write(json);
            }

            condition += Utility.GetHousingCondition();

            string use = HttpContext.Current.Request["roid"] != null ? HttpContext.Current.Request["roid"].ToString() : "";
            if (!string.IsNullOrEmpty(use))
            {
                string[] a = use.Split(',');
                if (a.Length > 1)
                {
                    condition += " and [use] in (" + use + ")";
                }
                else
                {
                    condition += " and [use] = " + use;
                }

            }
            if (!string.IsNullOrEmpty(city1) && city1 != "0")
            {
                condition += " and dID=" + city1;
            }
            if (!string.IsNullOrEmpty(city2) && city2 != "0")
            {
                condition += " and aID=" + city2;
            }
                        if (typeid == 1)
            {
                int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
                condition += " and (status = 1 or (status1 > 1 and status = 2)) and isvalid < 2 ";

                                if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
                {
                    string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                    if (!area.Equals(""))
                        condition += " and " + area;
                }

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_new(userid, page, pagesize, condition, orderByName, orderByType);
            }
            else if (typeid == 2)
            {
                if (userid > 0)
                    condition += " and userid=" + userid;
                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_favorite(userid, page, pagesize, condition, orderByName, orderByType);
            }
            else if (typeid == 3)
            {
                condition += " and status = 1";

                if (SalesManagerStation.Contains(station))
                    condition += " and markudeptid in(" + allchildrenDept + ")";
                else
                    condition += " and markuid = " + userid;

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_my(userid, page, pagesize, condition, orderByName, orderByType);
            }
            else if (typeid == 4)            {
                condition += " and recommend=1";
                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition, orderByName, orderByType);
            }
            else if (typeid == 5)            {
                condition += " and status = 1";
                orderByName = "markDate";
                orderByType = "desc";

                if (SalesManagerStation.Contains(station))
                    condition += " and markudeptid in(" + allchildrenDept + ")";
                else
                    condition += " and markuid = " + userid;
                condition += " and ((datediff(day,UDDate,getdate()) > (select top 1 itemValue-(select top 1 itemValue from dbo.t_system_option where item='当前盘待转资料盘提前提醒天数' and subsidiary in ('总公司', '" + _Utility.GetInfoBySession().m_sFgs + "') order by ID desc) from dbo.t_system_option where item='当前盘转资料盘天数' and subsidiary in ('总公司', '" + _Utility.GetInfoBySession().m_sFgs + "') order by ID desc) and [use] in (1,4))";

                condition += " or (datediff(day,UDDate,getdate()) > (select top 1 itemValue-(select top 1 itemValue from dbo.t_system_option where item='当前盘待转资料盘提前提醒天数' and subsidiary in ('总公司', '" + _Utility.GetInfoBySession().m_sFgs + "') order by ID desc) from dbo.t_system_option where item='工商盘转资料盘天数' and subsidiary in ('总公司', '" + _Utility.GetInfoBySession().m_sFgs + "') order by ID desc) and [use] not in (1,4))) ";

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_my(userid, page, pagesize, condition, orderByName, orderByType);
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingListByTradetype()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int eid = _Request.GetInt("eid", 0);
            int tradetype = _Request.GetInt("tradetype", 0);                  int page = _Request.GetInt("page", 1);
            int pagesize = _Request.GetInt("pagesize", 20);

            string buildIdList = BuildBLL.BuildIdListByEid(eid);
            string condition = " where dltFlag=0 and tradetype = " + tradetype;

            if (buildIdList != "")
                condition += " and buildid in(" + buildIdList + ")";
            else
                condition += " and buildid in(-1)";

            string json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingDel()
        {
            string outmsg = "";
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');

                        string SalesManagerStation = _Utility.GetWebConfigSetting("SalesManagerStation");

            if (IDList != null && IDList.Length > 0)
            {
                for (int i = 0; i < IDList.Length; i++)
                {
                    int id = _Convert.ToInt(IDList[i], 0);
                    ZLDC.Topo.Model.Estate.HousingInfo info = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_detail(id);
                    if ((info.MarkUDeptId.ToString() == _Utility.GetInfoBySession().m_sDeptID && ZLDC.Common.BaseUser.UserInfo.GetPopedom("删除盘源")) || ZLDC.Common.BaseUser.UserInfo.GetPopedom("删除全部盘源"))                    {

                        outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.HousingDelete(id, info.RoomId, info.TradeType);
                                                ZLDC.Topo.BLL.Estate.OperationlogBLL.p_operationlog_insert("t_housing", id, 3, "删除盘源");

                    }
                    else if (SalesManagerStation.Contains(_Utility.GetInfoBySession().m_sStation))                    {
                        string GetParentIdById = ZLDC.DAL.Estate.DeptDAL.GetParentIdById(info.MarkUDeptId);

                        if (GetParentIdById == _Utility.GetInfoBySession().m_sDeptID && ZLDC.Common.BaseUser.UserInfo.GetPopedom("删除盘源"))
                        {
                            outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.HousingDelete(id, info.RoomId, info.TradeType);
                                                        ZLDC.Topo.BLL.Estate.OperationlogBLL.p_operationlog_insert("t_housing", id, 3, "删除盘源");

                        }
                        else
                        {
                            outmsg = "对不起，您无权删除该盘源！";
                        }

                    }
                    else
                    {
                        outmsg = "对不起，您无权删除该盘源！";
                    }
                }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void HousingRecommend()
        {
            string outmsg = "";
            int id = _Request.GetInt("id", 0);
            int isrecommend = _Request.GetInt("isrecommend", 0);

            if (id > 0)
            {
                outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.HousingRecommend(id, isrecommend);
            }
            else
            {
                string[] IDList = _Utility.GetStringBySplit(_Request.GetString("idlist"), '|');

                if (IDList != null && IDList.Length > 0)
                {
                    for (int i = 0; i < IDList.Length; i++)
                    {
                        outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.HousingRecommend(_Convert.ToInt(IDList[i], 0), isrecommend);
                    }
                }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void HousingFavorite()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string user = _Utility.GetInfoBySession().m_sUserName;

            string outmsg = "";
            int id = _Request.GetInt("id", 0);
            int isfavorite = _Request.GetInt("isfavorite", 0);

            if (id > 0)
            {
                outmsg = ZLDC.Topo.BLL.Estate.HousingfavoriteBLL.HousingFavoriteDel(userid, id);
            }
            else
            {
                string[] IDList = _Utility.GetStringBySplit(_Request.GetString("idlist"), '|');

                if (IDList != null && IDList.Length > 0)
                {
                    for (int i = 0; i < IDList.Length; i++)
                    {
                        outmsg = ZLDC.Topo.BLL.Estate.HousingfavoriteBLL.p_housingfavorite_save(0, userid, user, _Convert.ToInt(IDList[i], 0), 0);
                    }
                }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                                public static void DelHousingFavorite()
        {
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("idlist"), '|');            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string outmsg = "";
            if (IDList != null && IDList.Length > 0)
            {
                for (int i = 0; i < IDList.Length; i++)
                {
                    outmsg = ZLDC.Topo.BLL.Estate.HousingfavoriteBLL.HousingFavoriteDel(userid, _Convert.ToInt(IDList[i]));
                }
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();

        }

                public static void HousingDetail()
        {
            int id = _Request.GetInt("id", 0);
            string json = CacheHousing.Cache_Detail_Json(id);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void HousingLock()
        {
            string outmsg = "";
            int isProtected = _Request.GetInt("isProtected", 0);               string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');

            if (IDList != null && IDList.Length > 0)
            {
                for (int i = 0; i < IDList.Length; i++)
                {
                    int id = _Convert.ToInt(IDList[i], 0);

                    outmsg = ZLDC.Topo.BLL.Estate.HousingBLL.HousingLock(id, isProtected);

                    if (isProtected == 0)
                    {
                        ZLDC.Topo.BLL.Estate.HousingExtendBLL.p_Housing_Extend_update(id);                    }
                                        if (id > 0)
                    {
                        _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
                        _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
                        _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + id);                     }

                }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void ListByType()
        {
            string type = _Request.GetString("type", "");
            string json = ZLDC.Topo.BLL.Estate.SystemParamBLL.SelectItemByType(type);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void GetOption()
        {
            string item = _Request.GetString("type", "");
            int json = ZLDC.Topo.BLL.Estate.SystemOptionBLL.GetOption(item);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void SelectHousig()
        {
            int id = _Request.GetInt("id", 0);
            string json = ZLDC.Topo.BLL.Estate.HousingBLL.SelectHousigById(id);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void ShowOtherHousing()
        {
            int id = _Request.GetInt("id", 0);

            string json = ZLDC.Topo.BLL.Estate.HousingBLL.ShowOtherHousing(id);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        #endregion

                public static void p_housingFollow_save()
        {
            int Id = _Request.GetIntForm("id", 0);
            int housingId = _Request.GetIntForm("housingId", 0);
            string followType = _Request.GetStringForm("followType", "");
            int fdeptId = _Request.GetIntForm("fdeptId", 0);
            string fdept = _Request.GetStringForm("fdept", "");
            int fUserId = _Request.GetIntForm("fUserId", 0);
            string fUser = _Request.GetStringForm("fUser", "");
            string fContent = _Request.GetStringForm("fcontent", "");
            string fprice = _Request.GetStringForm("fprice", "");
            string funitprice = _Request.GetStringForm("funitprice", "");
            string cbo1 = _Request.GetStringForm("cboname", "");
            string fImportant = _Request.GetStringForm("fImportant", "");
            string isalert = _Request.GetStringForm("isalert", "");
            if (fprice != "")
            {
                fContent = fContent + "-->" + "最新总价：" + fprice + "万";
            }
            if (funitprice != "")
            {
                fContent = fContent + "  最新租价：" + funitprice + "元";
            }

            if (fprice == "") fprice = "0";
            if (funitprice == "") funitprice = "0";

            HousingInfo info = HousingBLL.p_housing_detail(housingId);            PriceReductionBLL.p_priceReduction_add(housingId, _Convert.ToInt(fprice, 0), _Convert.ToFloat(funitprice, 0));          

            if (info.Mark5 != fImportant)
            {
                string station = _Utility.GetInfoBySession().m_sStation;                if (info.MarkUId.ToString() == _Utility.GetInfoBySession().m_sUserID || _Utility.GetWebConfigSetting("SalesManagerStation").Contains(station))                    ZLDC.Topo.BLL.Estate.HousingBLL.UpdateMark5(housingId, fImportant);            }
            else
            {
                fImportant = "";
            }

            string outmsg = "";
            int newid = 0;

            if (fContent != "")
            {
                int dltFlag = 0;
                outmsg = ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(Id, housingId, followType, fdeptId, fdept, fUserId, fUser, fContent, dltFlag, fImportant, ref newid);
                if (outmsg == "添加成功")
                {
                    using (_Database db = new _Database("estate"))
                    {
                        ZLDC.DAL.Estate.HousingDAL.UpdateTotalPrice(info.TradeType, fprice, funitprice, housingId, db);
                    }
                }
                if (Id == 0)
                {
                    quantificationBLL.UpdateHousingFollowQuantification(followType, fUserId, fdeptId, fUser, fdept);
                    if (followType == "家访")
                    {
                        int typeid = 19;
                        int visit = 0;

                        if (quantificationBLL.isExitByTypeId(typeid, housingId) == 0)
                        {
                            visit = 1;
                        }

                        quantificationBLL.UpdateCustomerOrHousingQuantification(typeid, housingId, visit, 0, 0, 0, 0);
                    }
                }

            }
            if (cbo1 == "0")
            {
                p_housingAlert_save();
            }
            if (isalert == "0")
            {
                p_housingInform_save();
            }

                        if (housingId > 0)
            {
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + housingId.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + housingId.ToString());
                _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + housingId);             }

            HttpContext.Current.Response.Write("<script>window.returnValue = " + newid + "; window.close();</script>");
        }

                public static void p_housingFollow_save2()
        {
            int Id = _Request.GetIntForm("id", 0);
            int housingId = _Request.GetInt("housingId", 0);
            string followType = _Request.GetString("followType", "");
            string tradetype = _Request.GetString("tradetype", "");

            int fdeptId = _Request.GetInt("fdeptId", 0);
            string fdept = _Request.GetString("fdept", "");
            int fUserId = _Request.GetInt("fUserId", 0);
            string fUser = _Request.GetString("fUser", "");

                                                
            string fContent = _Request.GetString("fcontent", "");
            float fprice = _Request.GetFloat("fprice", 0);
            float funitprice = _Request.GetFloat("funitprice", 0);
            string cbo1 = _Request.GetString("cboname", "");
            string fImportant = _Request.GetString("fImportant", "");
            string isalert = _Request.GetString("isalert", "");
            if (fprice >= 0 && tradetype == "1")
            {
                fContent = fContent + "-->" + "最新总价：" + fprice + "万";
            }
            if (funitprice >= 0 && tradetype == "2")
            {
                fContent = fContent + "-->最新租价：" + funitprice + "元";
            }

            string outmsg = "";
            int newid = 0;

            HousingInfo info = HousingBLL.p_housing_detail(housingId);            PriceReductionBLL.p_priceReduction_add(housingId, fprice, funitprice);          

            if (info.Mark5 != fImportant)            {
                string station = _Utility.GetInfoBySession().m_sStation;                if (info.MarkUId.ToString() == _Utility.GetInfoBySession().m_sUserID || _Utility.GetWebConfigSetting("SalesManagerStation").Contains(station))                    ZLDC.Topo.BLL.Estate.HousingBLL.UpdateMark5(housingId, fImportant);            }
            else
            {
                fImportant = "";
            }

            if (fContent != "")
            {
                int dltFlag = 0;
                outmsg = ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(Id, housingId, followType, fdeptId, fdept, fUserId, fUser, fContent, dltFlag, fImportant, ref newid);
                if (outmsg == "添加成功")
                {
                    using (_Database db = new _Database("estate"))
                    {
                        ZLDC.DAL.Estate.HousingDAL.UpdateTotalPrice(info.TradeType, fprice.ToString(), funitprice.ToString(), housingId, db);
                    }
                }
                else
                {
                    HttpContext.Current.Response.Write(outmsg);
                    HttpContext.Current.Response.End();
                }

                if (Id == 0)
                {
                    quantificationBLL.UpdateHousingFollowQuantification(followType, fUserId, fdeptId, fUser, fdept);
                    if (followType == "家访")
                    {
                        int typeid = 19;
                        int visit = 0;
                                                if (quantificationBLL.isExitByTypeId(typeid, housingId) == 0)
                        {
                            visit = 1;
                            quantificationBLL.UpdateCustomerOrHousingQuantification(typeid, housingId, visit, 0, 0, 0, 0);
                        }

                    }
                }

            }
            if (cbo1 == "0")
            {
                p_housingAlert_save();
            }
            if (isalert == "0")
            {
                p_housingInform_save();
            }

                        if (housingId > 0)
            {
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + housingId.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + housingId.ToString());
                _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + housingId);             }

            HttpContext.Current.Response.Write("");
            HttpContext.Current.Response.End();
        }

                public static void p_housingAlert_save()
        {
            int Id = 0;
            int housingId = _Request.GetIntForm("housingId", 0);
            string AlertType = _Request.GetStringForm("AlertType", "");
            string AlertScope = _Request.GetStringForm("AlertScope", "");
            string userid = "";
            int scope = 0;
            if (AlertScope == "本人")
            {
                userid = _Utility.GetInfoBySession().m_sUserID;
                scope = 1;
            }
            else if (AlertScope == "本部")
            {
                userid = _Utility.GetInfoBySession().m_sDeptID;
                scope = 2;
            }
            DateTime AlertDate = Convert.ToDateTime(_Request.GetStringForm("AlertDate", ""));
            string AlertContent = _Request.GetStringForm("AlertContent", "");
            int AddDeptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string AddDept = _Utility.GetInfoBySession().m_sDeptName;
            int AddUserId = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string AddUser = _Utility.GetInfoBySession().m_sUserName;
            int dFlag = _Request.GetIntForm("dFlag", 0);            int dDeptId = _Request.GetIntForm("dDeptId", 0);
            string dDept = _Request.GetStringForm("dDept", "");
            int dUserId = _Request.GetIntForm("dUserId", 0);
            string dUser = _Request.GetStringForm("dUser", "");
            int dltFlag = 0;            string outmsg = ZLDC.Topo.BLL.Estate.HousingAlertBLL.p_housingAlert_save(Id, housingId, AlertType, scope.ToString(), AlertDate, AlertContent, AddDeptId, AddDept, AddUserId, AddUser, dFlag, dDeptId, dDept, dUserId, dUser, dltFlag);

            quantificationBLL.UpdateHousingAlertQuantification(AlertType);

            HttpContext.Current.Response.Write("<script>window.close();</script>");

        }

                public static void p_housingInform_save()
        {
            int ID = 0;
            int housingId = _Request.GetIntForm("housingId", 0);
            string reason = string.Empty;
            reason = _Request.GetStringForm("reason", "");
            string advise = _Request.GetStringForm("advise", "");
            int informDeptId = _Request.GetIntForm("fdeptId", 0);
            string informDept = _Request.GetStringForm("fdept", "");
            int informUserId = _Request.GetIntForm("fUserId", 0);
            string informUser = _Request.GetStringForm("fUser", "");
            int dDeptId = _Request.GetIntForm("deptid", 0);
            string dUserId = _Request.GetStringForm("ddlusername", "");
            string dUser = "";
            string dDept = "";
            ZLDC.Topo.Model.Estate.UserInfo userinfo;

            if (dDeptId > 0)
            {
                using (_Database db = new _Database("estate"))
                {
                    userinfo = ZLDC.DAL.Estate.UserDAL.GetUserInfoByUserNo(dUserId, db);
                }
                dUser = userinfo.Name;
                dUserId = userinfo.Id.ToString();
                dDept = userinfo.DeptName;
                dDeptId = userinfo.Dept_id;
            }
                        string dView = _Request.GetStringForm("reason1", "");
            string dResult = "";
            int dltFlag = 0;            int isValid = _Request.GetIntForm("isValid", 1);            string outmsg = "";
            int userid = _Convert.ToInt(dUserId);
            outmsg = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housingInform_save(ID, housingId, reason, advise, informDeptId, informDept, informUserId, informUser, dDeptId, dDept, userid, dUser, dView, dResult, dltFlag, isValid);
            if (outmsg == "添加成功")
            {
                HttpContext.Current.Response.Write("<script>window.close();</script>");
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('保存举报失败')</script>");

            }
        }

                public static void p_housingFollow_delete()
        {

            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');
            int id = 0;
            string outmsg = "";
            for (int i = 0; i < IDList.Length; i++)
            {
                id = Convert.ToInt32(IDList[i]);
                outmsg = ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_delete(id);

                                if (id > 0)
                {
                    _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
                    _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
                    _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + id);                 }
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void p_housingFollow_list_table()
        {
            int housingId = _Request.GetInt("id", 0);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pageSize", 0);
            int deptid = _Request.GetInt("deptid", 0);
            int refresh = _Request.GetInt("refresh", 0);  
            if (refresh == 1)
                CacheHousingFollow.Cache_Follow_Json_Clear(page, pagesize, housingId, deptid);

            string json = CacheHousingFollow.Cache_Follow_Json(page, pagesize, housingId, deptid);

            
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingInform_list_table()
        {
            int housingId = _Request.GetInt("id", 0);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pageSize", 0);
            int isValid = _Request.GetInt("isValid", 3);
            int deptid = _Request.GetInt("deptid", 0);
            string IdList = _Request.GetString("IdList", "");            string rolename = _Request.GetString("rolename", "");
            string duserid = _Request.GetString("duserid", "");

            string json = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housingInform_list_table(page, pagesize, housingId, isValid, deptid, IdList, rolename, duserid);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        public static void SelectALerts()
        {
            int userid = _Request.GetInt("id", 0);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pageSize", 0);

            string json = ZLDC.Topo.BLL.Estate.HousingAlertBLL.p_AlertByUserid(page, pagesize, userid);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingAlert_list_table()
        {
            int housingId = _Request.GetInt("id", 0);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pageSize", 0);

            string json = ZLDC.Topo.BLL.Estate.HousingAlertBLL.p_housingAlert_list_table(page, pagesize, housingId, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID));
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingInform_update()
        {
            int id = 0;
            int deptid = _Request.GetInt("deptid", 0);
            string dept = _Request.GetString("dept", "");
            int duserid = _Request.GetInt("userid", 0);
            string duser = _Request.GetString("user", "");
            string dview = _Request.GetString("dview", "");
            string dresult = _Request.GetString("dresult", "");
            int isValid = _Request.GetInt("isValid", 0);
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');
            string outmsg = "";
            for (int i = 0; i < IDList.Length; i++)
            {
                id = Convert.ToInt32(IDList[i]);
                outmsg = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housingInform_update(id, deptid, dept, duserid, duser, dview, dresult, isValid);

            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void p_housingAlert_update()
        {
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');
            int id = 0;
            string json = "";
            int dflag = _Request.GetInt("dflag", 1);            int deptid = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            int duserid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string duser = _Utility.GetInfoBySession().m_sUserName;


            for (int i = 0; i < IDList.Length; i++)
            {
                id = Convert.ToInt32(IDList[i]);
                json = ZLDC.Topo.BLL.Estate.HousingAlertBLL.p_housingAlert_update(id, dflag, deptid, dept, duserid, duser);

            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingAlert_delete()
        {
            string[] IDList = _Utility.GetStringBySplit(_Request.GetString("id"), '|');
            int id = 0;
            string json = "";
            for (int i = 0; i < IDList.Length; i++)
            {
                id = Convert.ToInt32(IDList[i]);
                json = ZLDC.Topo.BLL.Estate.HousingAlertBLL.p_housingAlert_delete(id);

            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();

        }

                public static void TellogList()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string station = _Utility.GetInfoBySession().m_sStation;
            int housingid = _Request.GetInt("id", 0);       
                        int itemvalue = ZLDC.Topo.BLL.Estate.SystemOptionBLL.GetOption("单个房源被翻看次数");                   int itemvalue3 = ZLDC.Topo.BLL.Estate.SystemOptionBLL.GetOption("单个房源被经理翻看次数");              int itemvalue2 = ZLDC.Topo.BLL.Estate.SystemOptionBLL.GetOption("翻看业主电话次数");        

            string usageList = ZLDC.DAL.Estate.DeptDAL.GetDeptUsageList(_Utility.GetInfoBySession().m_sDeptID);
                        if (usageList == "商业")
                itemvalue2 = ZLDC.Topo.BLL.Estate.SystemOptionBLL.GetOption("翻看业主电话(工商)"); 


                        int count = ZLDC.Topo.BLL.Estate.LookTelLogBLL.LookTelCount(housingid, userid, 1);
            int count2 = ZLDC.Topo.BLL.Estate.LookTelLogBLL.LookTelCount(housingid, userid, 2);

                        
           


            if (station.Contains("置业顾问"))
            {

            }
            else if (station.Contains("分行经理"))
            {
                itemvalue = (itemvalue3 + itemvalue);
            }
            else
            {
                itemvalue = 10000;
            }

            if (count >= itemvalue)
                HttpContext.Current.Response.Write("1");
            else if (count2 >= itemvalue2)
                HttpContext.Current.Response.Write("2");
            else
            {
                int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
                string dept = _Utility.GetInfoBySession().m_sDeptName;
                string user = _Utility.GetInfoBySession().m_sUserName;
                string lookpost = _Utility.GetInfoBySession().m_fhName;     
                ZLDC.Topo.BLL.Estate.LookTelLogBLL.p_LookTelLog_insert(housingid, deptId, dept, userid, user, lookpost);
                                string json = ZLDC.Topo.BLL.Estate.LookTelLogBLL.p_LookTelLog_list(housingid);
                                quantificationBLL.UpdateTelQuantification();

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(json);
                HttpContext.Current.Response.End();
            }
        }

                public static void p_huosing_pic_listall_table()
        {
            int id = _Request.GetInt("eid", 0);
            string json = ZLDC.Topo.BLL.Estate.HuosingPicBLL.p_huosing_pic_listall_table(id);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_estate_pic_listall_table()
        {
            int id = _Request.GetInt("eid", 0);            int eid = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildIdByHid(id);            int tyep = _Request.GetInt("type", 0);
            string json = ZLDC.Topo.BLL.Estate.EstatePicBLL.EstatePicList(eid, tyep);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingKey_Save()
        {
            int id = _Request.GetInt("kid", 0);
            int housingId = _Request.GetInt("eid", 0);
            string KeyNo = _Request.GetString("keyno", "");
            string userid = _Request.GetString("userid", "");
            string Operator = _Request.GetString("Operator", "");

            ZLDC.Topo.Model.Estate.UserInfo userinfo;
            using (_Database db = new _Database("estate"))
            {
                userinfo = ZLDC.DAL.Estate.UserDAL.GetUserInfoByUserNo(userid, db);
            }
            int borrowerDeptID = _Convert.ToInt(userinfo.Dept_id.ToString());
            string borrowerDept = userinfo.DeptName;
            int borrowerID = _Convert.ToInt(userinfo.Id.ToString());
            string borrower = userinfo.Name;
            int receiverID = userinfo.Id;
            string receiver = userinfo.Name;
            string json = ZLDC.Topo.BLL.Estate.HousingKeyBLL.p_housingKey_save(id, housingId, KeyNo, borrowerDeptID, borrowerDept, borrowerID, borrower, receiverID, receiver, Operator);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingKey_list_table()
        {
            int housingid = _Request.GetInt("eid", 0);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pageSize", 0);
            string json = ZLDC.Topo.BLL.Estate.HousingKeyBLL.p_housingKey_list_table(page, pagesize, housingid);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingInform_updateisValid()
        {
            int id = _Request.GetInt("id", 0);
            int isValid = _Request.GetInt("isValid", 3);
            string json = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housingInform_updateisValid(id, isValid);

                        if (id > 0)
            {
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        public static void p_housingInform_updateisResult()
        {
            int id = _Request.GetInt("id", 0);
            int isValid = _Request.GetInt("isValid", -1);
            string dept = _Request.GetString("dept", "");
            int deptid = _Request.GetInt("deptid", 0);
            string duser = _Request.GetString("duser", "");
            int duserid = _Request.GetInt("duserid", 0);
            string dresult = _Request.GetString("dresult", "");
            string json = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housingInform_updateisResult(id, deptid, dept, duserid, duser, dresult, isValid);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        public static void p_housingInform_ResultList_table()
        {
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pageSize", 0);
            int isValid = _Request.GetInt("isValid", 3);
            string result = _Request.GetString("result", "");
            string IdList = _Request.GetString("IdList", "");
            string deptname = _Request.GetString("deptname", "");
            string starttime = _Request.GetString("time1", "");
            string endtime = _Request.GetString("time2", "");
            string json = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housingInform_ResultList_table(page, pagesize, isValid, result, IdList, deptname, starttime, endtime);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void UpdateStatus()
        {
            string id = "";
            int deptid_from = _Request.GetInt("deptid_from", 0);            string deptname_from = _Request.GetString("deptname_from", "");
            int userid_from = _Request.GetInt("userid_from", 0);

            string username_from = _Request.GetString("username_from", "");
            string flag = _Request.GetString("flag", "");

            string userid_to = _Request.GetString("userid_to", "");            int deptid_to = _Request.GetInt("deptid_to", 0);
            string username_to = _Request.GetString("username_to", "");
            string deptname_to = _Request.GetString("deptname_to", "");
            ZLDC.Topo.Model.Estate.UserInfo user = ZLDC.Topo.BLL.Estate.UserBLL.GetUserInfoByUserNo(userid_to);            if (user == null)
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write("楼盘系统中没有此用户(" + username_to + ")！");
                HttpContext.Current.Response.End();
            }
            int uid_to = user.Id;

            int rows = 0;

            string HousingId = _Request.GetString("id", "");
            string[] IdList = null;
            if (HousingId != "")
            {
                IdList = _Utility.GetStringBySplit(HousingId, '|');
                if (IdList.ToString() != "")
                {
                    for (int i = 0; i < IdList.Length; i++)
                    {
                        id += IdList[i].ToString() + ",";

                                                if (_Convert.ToInt(IdList[i].ToString()) > 0)
                        {
                            _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + IdList[i].ToString());
                            _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + IdList[i].ToString());
                            _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + IdList[i].ToString());
                        }
                    }
                    if (id.Length > 0)
                    {
                        id = id.Substring(0, id.Length - 1);
                    }
                }
            }
            if (username_from != "" && userid_from > 0 && deptid_from > 0 && deptname_from != "")
            {
                deptname_to = deptname_to.Substring(1, deptname_to.Length - 1);
                rows = ZLDC.Topo.BLL.Estate.HousingBLL.UpdateStatus(id, deptid_from, deptname_from, userid_from, username_from, flag, uid_to, deptid_to, deptname_to, username_to);
            }
            string outmsg = "";
            if (rows > 0)
            {
                                if (HousingId != "")
                {
                    for (int j = 0; j < IdList.Length; j++)
                    {
                        int hID = _Convert.ToInt(IdList[j]);                        ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, hID, "业务员转盘", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID.ToString()), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID.ToString()), _Utility.GetInfoBySession().m_sUserName, "经理转盘：[转出人:" + username_from + ",转入人:" + username_to + "]", 0, "");
                                                if (hID > 0)
                            _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + hID);
                    }
                }
                outmsg = "操作成功！";
            }
            else
            {
                outmsg = "操作失败，请联系管理员！";
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void p_housing_updateisValid()
        {
            int id = _Request.GetInt("id", 0);
            string advise = _Request.GetString("advise", "");
            string json = ZLDC.Topo.BLL.Estate.HousingInformBLL.p_housing_updateisValid(id, advise);

                        if (id > 0)
            {
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
                _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
            }

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_HosingPic_insert()
        {
            int id = _Request.GetInt("id", 0);
            string arrpicurl = _Request.GetString("picurl", "");
            int type = 2;
            DataSet ds1 = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(id);
            string estatename = ds1.Tables[0].Rows[0]["buildName"].ToString();            string hroomno = ds1.Tables[0].Rows[0]["roomno"].ToString();            int dltflag = 0;
            Array arr = arrpicurl.Split(',');

            string json = string.Empty;
            foreach (var item in arr)
            {
                json = ZLDC.Topo.BLL.Estate.HuosingPicBLL.p_huosing_pic_insert(item.ToString(), "", "", type, id, estatename, hroomno, "", dltflag);

            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housingFollowReport_list_table()
        {
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            string StratTime = _Request.GetString("startTime", "");
            string EndTIME = _Request.GetString("EndTime", "");
            string deptid ="322";                 int flwtype = _Request.GetInt("flwtype", 0);            

            string uName = string.Empty;             string uNo = string.Empty;               int userId = 0;                 
            string userNameList = _Request.GetString("UserName", "");


            if (StratTime == "" && EndTIME == "")
            {
                StratTime = DateTime.Now.ToString("yyyy-MM-dd");

                EndTIME = DateTime.Now.ToString("yyyy-MM-dd");
            }

            string IdList1 = "";            DataTable dt = ZLDC.DAL.Estate.DeptDAL.getGetAllChildrenDept(deptid);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["id"].ToString() != "")
                    IdList1 += dt.Rows[i]["id"].ToString() + ",";
            }

            if (IdList1 != "")
                IdList1 = IdList1.Substring(0, IdList1.Length - 1);

            string station = _Utility.GetInfoBySession().m_sStation;

            string condition = "  where 1=1 ";
            if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源跟进"))
            {
                if (IdList1 != "")
                {
                    condition += " and fdeptid in(" + IdList1 + ") ";
                }
            }
            else
            {
                if (_Utility.GetWebConfigSetting("SalesManagerStation").Contains(station))                {
                    string IdList = CacheUtility.Cache_GetAllChildDept(_Utility.GetInfoBySession().m_sDeptID);

                    if (deptid != "")
                        condition += " and fdeptid in(" + IdList1 + ")   and fdeptid in(" + IdList + ") ";
                    else
                        condition += " and fdeptid in(" + IdList + ") ";
                }
                else if (userNameList.Contains("["))                {

                    _Utility.GetUserNoAndUserName(userNameList.Trim(), out uName, out uNo);

                    if (uName != "")                    {
                        userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(uNo);
                    }

                    if (userId.ToString() != _Utility.GetInfoBySession().m_sUserID)
                        condition += " and fdeptid=" + _Utility.GetInfoBySession().m_sDeptID + "  ";

                }
                else
                {
                                                            condition += " and fdeptid=" + _Utility.GetInfoBySession().m_sDeptID + "  ";
                }
            }


            if (StratTime != "" && EndTIME != "")
                condition += "  and fdate between '" + StratTime + " 00:00:00" + "' and '" + EndTIME + " 23:59:59" + "' ";



            if (_Convert.ToInt(userNameList, 0) > 0)
                condition += " AND FUSERId='" + userNameList + "' ";
            else
            {
                if (userNameList != "")                {
                    _Utility.GetUserNoAndUserName(userNameList.Trim(), out uName, out uNo);

                    if (uName != "")                    {
                        userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(uNo);

                        condition += " AND FUSERId='" + userId.ToString() + "' ";
                    }
                    else
                        condition += " AND FUSERId='" + userNameList + "' ";
                }
                                                                
                                                            }

            if (flwtype > 0)
            {
                if (flwtype == 2)
                    condition += " AND followtype='自看房'";
                else if (flwtype == 21)
                    condition += " and followtype='家访'";
                else                    condition += " AND followtype in ( select item from t_system_param where type='跟进方式')";
            }

            string json = ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollowReport_list_table(page, pagesize, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                public static void p_housing_Key_Report_list_table()
        {
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            string StratTime = _Request.GetString("startTime", "");
            string EndTIME = _Request.GetString("EndTime", "");
            string deptid = _Request.GetString("deptname", "");
            string userNameList = _Request.GetString("UserName", "");

            string IdList1 = "";            DataTable dt = ZLDC.DAL.Estate.DeptDAL.getGetAllChildrenDept(deptid);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["id"].ToString() != "")
                {
                    IdList1 += dt.Rows[i]["id"].ToString() + ",";
                }
            }
            if (IdList1 != "")
            {
                IdList1 = IdList1.Substring(0, IdList1.Length - 1);
            }
            string station = _Utility.GetInfoBySession().m_sStation;

            string condition = "  where dltFlag=0 ";
            if (ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部钥匙信息明细"))
            {
                if (IdList1 != "")
                {
                    condition += " and deptid in(" + IdList1 + ") ";
                }
            }
            else
            {
                if (_Utility.GetWebConfigSetting("SalesManagerStation").Contains(station))
                {
                    string IdList = CacheUtility.Cache_GetAllChildDept(_Utility.GetInfoBySession().m_sDeptID);

                    if (deptid != "")
                    {
                        condition += " and deptid in(" + IdList1 + ")   and deptid in(" + IdList + ") ";
                    }
                    else
                    {
                        condition += " and deptid in(" + IdList + ") ";
                    }
                }
                else
                {
                                        if(_Utility.GetInfoBySession().m_sRoleID=="29"){
                        string DeptIdList=ZLDC.Common.BaseUser.UserInfo.GetManagePosDeptList(_Convert.ToInt(_Utility.GetInfoBySession().m_sEHRUserID));
                        condition += " and deptid in(" +DeptIdList+ ") ";
                    }
                    else{
                        condition += "   and userid=" + _Utility.GetInfoBySession().m_sUserID + " ";
                    }
                }
            }
            if (StratTime != "" && EndTIME != "")
            {
                condition += "  and countDate  between '" + StratTime + " 00:00:00' and '" + EndTIME + " 23:59:59' ";
            }

            if (userNameList != "")
            {
                string userName = string.Empty;                 string userNo = string.Empty;   
                _Utility.GetUserNoAndUserName(userNameList.Trim(), out userName, out userNo);
                int userId = 0;                                 userId = ZLDC.Topo.BLL.Estate.UserBLL.GetUserIDByUserNo(userNo);

                condition += " and userid=" + userId + "";

            }

            string json = ZLDC.Topo.BLL.Estate.HousingKeyBLL.p_housing_Key_Report_list_table(page, pagesize, condition);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        #region 房源匹配

                public static void HousingMatch()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);

            string area = _Request.GetString("area", "");                     string usage = _Request.GetString("usage", "");                     string buildname = _Request.GetString("buildname", "");             string tradetype = _Request.GetString("tradetype", "");             int minPrice = _Request.GetInt("minPrice", 0);                      int maxPrice = _Request.GetInt("maxPrice", 0);                      int minAcreage = _Request.GetInt("minAcreage", 0);                  int maxAcreage = _Request.GetInt("maxAcreage", 0);                  int room = _Request.GetInt("room", 0);                              string direct = _Request.GetString("direct", "");                   string fitment = _Request.GetString("fitment", "");       
            string condition = " where dltFlag=0 and isvalid < 2 "; 
                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string areas = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + areas;
            }

            if (usage != "")
                condition += " and [use] = (select mark3 from t_system_param where type='用途' and item='" + usage + "')";

            if (room > 0)
                condition += " and room = " + room;

            if (direct != "")
                condition += " and charindex(direct, '" + direct + "')>0";

            if (fitment != "")
                condition += " and fitment = '" + fitment + "'";

            if (minPrice >= 0 && maxPrice > 0)
                condition += " and totalprice >=" + minPrice + " and totalprice < " + maxPrice;

            if (minAcreage >= 0 && maxAcreage > 0)
                condition += " and acreage >=" + minAcreage + " and acreage < " + maxAcreage;

            if (area != "" && !area.Contains("全部"))
                condition += " and CHARINDEX(area, '" + area + "') > 0";

            if (buildname != "")
                condition += " and CHARINDEX(ename, '" + buildname + "') > 0";

            string json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list(userid, page, pagesize, condition, "status", "asc");

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        #endregion

        #region 每日一盘

                public static void HousingEverydayAdd()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string user = _Utility.GetInfoBySession().m_sUserName;

            string outmsg = "推荐失败";
            int id = _Request.GetInt("id", 0);

            if (id > 0)
                outmsg = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.p_housingEveryday_insert(userid, user, id, 0);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                public static void HousingEverydayList()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                        int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            int typeid = _Request.GetInt("typeid", 0);
                        string orderByName = _Request.GetString("orderByName", "");
            string orderByType = _Request.GetString("orderByType", "desc");

            string condition = " where dltFlag=0 and isvalid < 2 and  type=" + typeid + " ";

                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
            }

            condition += Utility.GetHousingCondition();

            string json = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.p_housingEveryday_list_table(page, pagesize, condition, orderByName, orderByType);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }
                public static void sql_HousingEverydayList()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                        int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            int typeid = _Request.GetInt("typeid", 0);
                        string orderByName = _Request.GetString("orderByName", "");
            string orderByType = _Request.GetString("orderByType", "desc");

            string condition = " where dltFlag=0 and isvalid < 2 and  type=" + typeid + " ";

                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
            }

            condition += Utility.GetHousingCondition();
            string sql = "select top 5 leaseprice,mark1,buildname,roomno,housingId,id,ename,room,hall,acreage,tradetype,totalprice from v_housingEveryday " + condition;
            string json = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.sql_housingEveryday_list_table(sql);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }
                public static void HousingEverydayDel()
        {
            string outmsg = "";
            int id = _Request.GetInt("id", 0);
            int typeid = _Request.GetInt("typeid", 0);
            outmsg = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.HousingEverydayDelete(id, typeid);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

                private static void DelPic()
        {
            string outmsg = "";
            int id = _Request.GetInt("id", 0);
            int deptid = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string IdList = CacheUtility.Cache_GetAllChildDept(_Utility.GetInfoBySession().m_sDeptID);
            string userid = _Request.GetString("userid", "");
            string station = _Utility.GetInfoBySession().m_sStation;

            outmsg = ZLDC.Topo.BLL.Estate.HuosingPicBLL.DelPic(id, IdList);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(outmsg);
            HttpContext.Current.Response.End();
        }

        #endregion

        #region 降价盘查询

                public static void HousingReductionList()
        {
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                
            int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);
            string city1 = _Request.GetString("city1", "0");            string city2 = _Request.GetString("city2", "0");                        string condition = "where dltFlag=0 and isvalid < 2 and price_new >0 ";

                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
            }

            string use = HttpContext.Current.Request["roid"] != null ? HttpContext.Current.Request["roid"].ToString() : "";
            if (!string.IsNullOrEmpty(use))
            {
                string[] a = use.Split(',');
                if (a.Length > 1)
                {
                    condition += " and [use] in (" + use + ")";
                }
                else
                {
                    condition += " and [use] = " + use;
                }

            }
            if (!string.IsNullOrEmpty(city1) && city1 != "0")
            {
                condition += " and dID=" + city1;
            }
            if (!string.IsNullOrEmpty(city2) && city2 != "0")
            {
                condition += " and aID=" + city2;
            }
            condition += Utility.GetHousingCondition();

                        string json = ZLDC.Topo.BLL.Estate.PriceReductionBLL.p_v_priceReduction_list_table(page, pagesize, condition);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        #endregion

        #region 成交盘查询

                public static void HousingTranctionList()
        {
            string json = "";

            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            int deptId = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID);
            string dept = _Utility.GetInfoBySession().m_sDeptName;
            string station = _Utility.GetInfoBySession().m_sStation;                        int page = _Request.GetInt("page", 0);
            int pagesize = _Request.GetInt("pagesize", 0);

                        string orderByName = _Request.GetString("orderByName", "");
            string orderByType = _Request.GetString("orderByType", "desc");
            string city1 = _Request.GetString("city1", "0");            string city2 = _Request.GetString("city2", "0");            string condition = " where dltFlag=0 and isvalid < 2 and status1=1";    
                        if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("查看全部盘源"))
            {
                string area = CacheUtility.Cache_GetAreaAndUseByDeptId(deptId);
                if (!area.Equals(""))
                    condition += " and " + area;
            }

            string use = HttpContext.Current.Request["roid"] != null ? HttpContext.Current.Request["roid"].ToString() : "";
            if (!string.IsNullOrEmpty(use))
            {
                string[] a = use.Split(',');
                if (a.Length > 1)
                {
                    condition += " and [use] in (" + use + ")";
                }
                else
                {
                    condition += " and [use] = " + use;
                }

            }
            if (!string.IsNullOrEmpty(city1) && city1 != "0")
            {
                condition += " and dID=" + city1;
            }
            if (!string.IsNullOrEmpty(city2) && city2 != "0")
            {
                condition += " and aID=" + city2;
            }
            int id = _Request.GetInt("id", 0);                                              if (id > 0)
            {
                condition += " and id=" + id;

                json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_action(userid, page, pagesize, condition, orderByName, orderByType);
                HttpContext.Current.Response.Write(json);
            }

            /*
            string usage = _Request.GetString("usage", "");                      if (usage != "" && usage != "全部" && usage != "无")
                condition += " and [use]='" + usage + "'";

            string buildName = _Request.GetString("name", "");                  if (buildName != "" && buildName != "楼盘名称、拼音均可")
            {
                string[] buildList = _Utility.GetStringBySplit(buildName, ',');
                condition += " and (";
                for (int i = 0; i < buildList.Length; i++)
                {
                    string item = buildList[i];

                    if (!item.Equals(""))
                    {
                        if (i == 0)
                            condition += " buildName like '%" + item + "%'";
                        else
                            condition += " or buildName like '%" + item + "%'";
                    }
                }
                condition += " )";
            }

            int room = _Request.GetInt("room", 0);                              if (room > 0)
                condition += " and room=" + room;

            int hall = _Request.GetInt("hall", 0);                              if (hall > 0)
                condition += " and hall=" + hall;

            int acreage1 = _Request.GetInt("acreage1", 0);                      int acreage2 = _Request.GetInt("acreage2", 0);                      if (acreage1 > 0 && acreage2 > 0)
                condition += " and acreage >=" + acreage1 + " and acreage < " + acreage2;

            int did = _Request.GetInt("did", 0);                                if (did > 0)
                condition += " and did=" + did;

            int aid = _Request.GetInt("aid", 0);                                if (aid > 0)
                condition += " and aid=" + aid;

            int status = _Request.GetInt("status", 0);                          if (status > 0)
                condition += " and status=" + status;

            int tradetype = _Request.GetInt("tradetype", 0);                    if (tradetype > 0)
                condition += " and tradeType=" + tradetype;

            int price1 = _Request.GetInt("price1", 0);                          int price2 = _Request.GetInt("price2", 0);                          if (price1 > 0 && price2 > 0)
            {
                if (tradetype == 1)
                    condition += " and totalprice >=" + price1 + " and totalprice < " + price2;
                else
                    condition += " and leaseprice >=" + price1 + " and leaseprice < " + price2;
            }

            int hasKey = _Request.GetInt("hasKey", 0);                              if (hasKey > 0)
                condition += " and hasKey=" + hasKey;

            int isOnly = _Request.GetInt("isOnly", 0);                              if (isOnly > 0)
                condition += " and isOnly=" + isOnly;

            int hasPhoto = _Request.GetInt("hasPhoto", 0);                          if (hasPhoto > 0)
                condition += " and hasPhoto=" + hasPhoto;

            int pocStatus = _Request.GetInt("pocStatus", 0);                        if (pocStatus > 0)
                condition += " and pocStatus='红本'";

            int mark2 = _Request.GetInt("mark2", 0);                                if (mark2 > 0)
                condition += " and mark2='满5年免税'";

                        string linkman = _Request.GetString("linkman", "");                     if (linkman != "")
                condition += " and owner='" + linkman + "'";

            string linktel = _Request.GetString("linktel", "");                     if (linktel != "")
                condition += " and ownertel='" + linktel + "'";

            int unitPrice1 = _Request.GetInt("unitPrice1", 0);                          int unitPrice2 = _Request.GetInt("unitPrice2", 0);                          if (unitPrice1 > 0 && unitPrice2 > 0)
                condition += " and unitPrice >=" + unitPrice1 + " and unitPrice < " + unitPrice1;

            string markUdept = _Request.GetString("markUdept", "");                     if (markUdept != "")
                condition += " and markUdept = '" + markUdept + "'";

            string adduser = _Request.GetString("adduser", "");                         if (adduser != "")
                condition += " and adduser = '" + adduser + "'";

            string fitment = _Request.GetString("fitment", "");                         if (fitment != "" && fitment != "全部")
                condition += " and fitment = '" + fitment + "'";

            string houseStyle = _Request.GetString("houseStyle", "");                   if (houseStyle != "" && houseStyle != "全部")
                condition += " and houseStyle = '" + houseStyle + "'";

            string direct = _Request.GetString("direct", "");                           if (direct != "" && direct != "全部")
                condition += " and direct = '" + direct + "'";

            string happliances = _Request.GetString("happliances", "");                     if (happliances != "")
                condition += " and happliances like '%" + happliances + "%'";

            string startdate = _Request.GetString("startdate", "");                         string enddate = _Request.GetString("enddate", "");
            if (startdate != "" && enddate != "")
                condition += " and AddDate > '" + startdate + "' and AddDate < '" + enddate + "'";

            string type = _Request.GetString("type", "");                                   if (type != "" && type != "全部" && type != "无")
                condition += " and [housetype]='" + type + "'";

            int floor1 = _Request.GetInt("floor1", 0);                                        int floor2 = _Request.GetInt("floor2", 0);                                        if (floor1 > 0 && floor2 > 0)
                condition += " and " + floor1 + " <= mark1 and mark1 <= " + floor2;
            else if (floor1 > 0)
                condition += " and mark1 = " + floor1;
            else if (floor2 > 0)
                condition += " and mark1 = " + floor2;
           
            */

            condition += Utility.GetHousingCondition();

            json = ZLDC.Topo.BLL.Estate.HousingBLL.p_housing_list_action(userid, page, pagesize, condition, orderByName, orderByType);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

                private static void HousingTranctionDetail()
        {
            int pty_id = _Request.GetInt("pty_id", 0);
            int kty_id = _Request.GetInt("kty_id", 0);

            string json = ZLDC.Topo.BLL.Estate.HousingBLL.p_transaction_detail_table(pty_id, kty_id);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();
        }

        #endregion

                public static void InsertHousingEveryDay()
        {
            string json = "";
            int userid = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID);
            string user = _Utility.GetInfoBySession().m_sUserName;
            int housingid = _Request.GetInt("housingid", 0);
            string content = _Request.GetString("content", "");
            DataSet ds = ZLDC.Topo.BLL.Estate.HousingBLL.SelectBuildNameById(housingid);

                        int hCount = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.SelectHousingByUserId(userid);
            if (hCount > 1)
            {
                json = "对不起，笋盘个数已超限,一天只能推荐一个笋盘";
            }
            else
            {
                string status = "";                 string isvalid = "";
                if (ds.Tables[0].Rows.Count > 0)
                {
                    status = ds.Tables[0].Rows[0]["status"].ToString();
                    isvalid = ds.Tables[0].Rows[0]["isvalid"].ToString();
                }

                if (status == "1" && isvalid == "0")
                {
                                        int num = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.SelectHousingEveryDay(housingid, 1);
                    if (num > 0)
                    {
                        json = "对不起，该盘源已被推荐，请推荐其它盘源！";
                    }
                    else
                    {

                        json = ZLDC.Topo.BLL.Estate.HousingEverydayBLL.InsertHousingEveryDay(userid, user, housingid, content);
                    }
                }
                else
                {
                    json = "对不起，推荐笋盘必须是有效当前盘！";
                }
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(json);
            HttpContext.Current.Response.End();

        }

                public static void UpdateMark4()
        {
            string mark4 = _Request.GetInt("mark4", 0).ToString();
            int id = _Request.GetInt("id", 0);
            ZLDC.Topo.BLL.Estate.HousingBLL.UpdateMark4(id, mark4);
            string fcontent = "";
            if (mark4 == "1")
            {
                fcontent = "标记无效";
            }
            else
            {
                fcontent = "取消标记无效";
            }
            _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_JSON + id.ToString());
            _Cache.Remove(CacheConst.CACHE_HOUSING_DETAIL_INFO + id.ToString());
            _Cache.RemoveLike(CacheConst.CACHE_HOUSING_FOLLOW_JSON + id);
            ZLDC.Topo.BLL.Estate.HousingFollowBLL.p_housingFollow_save(0, id, "", _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID), _Utility.GetInfoBySession().m_sDeptName, _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID), _Utility.GetInfoBySession().m_sUserName, fcontent, 0, "");
        }
                                public static void GetInfo()
        {
            int userid = 0;
            if (HttpContext.Current.Session["info"] == null)
            {
                userid = 1;
            }
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(userid);
            HttpContext.Current.Response.End();

        }
    }
}
